PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/autotools/automake.html_node/Third_002dParty-Makefiles.html

https://gitlab.com/Gentio/my-pdf
HTML | 272 lines | 216 code | 15 blank | 41 comment | 0 complexity | 379940b4930b6e7ff55ed072cfb890ef MD5 | raw file
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!--
  4. This manual is for GNU Automake (version 1.15,
  5. 31 December 2014), a program that creates GNU standards-compliant
  6. Makefiles from template files.
  7. Copyright (C) 1995-2014 Free Software Foundation, Inc.
  8. Permission is granted to copy, distribute and/or modify this document
  9. under the terms of the GNU Free Documentation License,
  10. Version 1.3 or any later version published by the Free Software
  11. Foundation; with no Invariant Sections, with no Front-Cover texts,
  12. and with no Back-Cover Texts. A copy of the license is included in the
  13. section entitled "GNU Free Documentation License."
  14. -->
  15. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  16. <head>
  17. <title>automake: Third-Party Makefiles</title>
  18. <meta name="description" content="automake: Third-Party Makefiles">
  19. <meta name="keywords" content="automake: Third-Party Makefiles">
  20. <meta name="resource-type" content="document">
  21. <meta name="distribution" content="global">
  22. <meta name="Generator" content="makeinfo">
  23. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  24. <link href="index.html#Top" rel="start" title="Top">
  25. <link href="Indices.html#Indices" rel="index" title="Indices">
  26. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  27. <link href="Not-Enough.html#Not-Enough" rel="up" title="Not Enough">
  28. <link href="Distributing.html#Distributing" rel="next" title="Distributing">
  29. <link href="Extending.html#Extending" rel="prev" title="Extending">
  30. <style type="text/css">
  31. <!--
  32. a.summary-letter {text-decoration: none}
  33. blockquote.smallquotation {font-size: smaller}
  34. div.display {margin-left: 3.2em}
  35. div.example {margin-left: 3.2em}
  36. div.indentedblock {margin-left: 3.2em}
  37. div.lisp {margin-left: 3.2em}
  38. div.smalldisplay {margin-left: 3.2em}
  39. div.smallexample {margin-left: 3.2em}
  40. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  41. div.smalllisp {margin-left: 3.2em}
  42. kbd {font-style:oblique}
  43. pre.display {font-family: inherit}
  44. pre.format {font-family: inherit}
  45. pre.menu-comment {font-family: serif}
  46. pre.menu-preformatted {font-family: serif}
  47. pre.smalldisplay {font-family: inherit; font-size: smaller}
  48. pre.smallexample {font-size: smaller}
  49. pre.smallformat {font-family: inherit; font-size: smaller}
  50. pre.smalllisp {font-size: smaller}
  51. span.nocodebreak {white-space:nowrap}
  52. span.nolinebreak {white-space:nowrap}
  53. span.roman {font-family:serif; font-weight:normal}
  54. span.sansserif {font-family:sans-serif; font-weight:normal}
  55. ul.no-bullet {list-style: none}
  56. -->
  57. </style>
  58. </head>
  59. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  60. <a name="Third_002dParty-Makefiles"></a>
  61. <div class="header">
  62. <p>
  63. 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> &nbsp; [<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>
  64. </div>
  65. <hr>
  66. <a name="Third_002dParty-Makefiles-1"></a>
  67. <h3 class="section">23.2 Third-Party <samp>Makefile</samp>s</h3>
  68. <a name="index-Third_002dparty-packages_002c-interfacing-with"></a>
  69. <a name="index-Interfacing-with-third_002dparty-packages"></a>
  70. <p>In most projects all <samp>Makefile</samp>s are generated by Automake. In
  71. some cases, however, projects need to embed subdirectories with
  72. handwritten <samp>Makefile</samp>s. For instance, one subdirectory could be
  73. a third-party project with its own build system, not using Automake.
  74. </p>
  75. <p>It is possible to list arbitrary directories in <code>SUBDIRS</code> or
  76. <code>DIST_SUBDIRS</code> provided each of these directories has a
  77. <samp>Makefile</samp> that recognizes all the following recursive targets.
  78. </p>
  79. <a name="index-recursive-targets-and-third_002dparty-Makefiles"></a>
  80. <p>When a user runs one of these targets, that target is run recursively
  81. in all subdirectories. This is why it is important that even
  82. third-party <samp>Makefile</samp>s support them.
  83. </p>
  84. <dl compact="compact">
  85. <dt><code>all</code></dt>
  86. <dd><p>Compile the entire package. This is the default target in
  87. Automake-generated <samp>Makefile</samp>s, but it does not need to be the
  88. default in third-party <samp>Makefile</samp>s.
  89. </p>
  90. </dd>
  91. <dt><code>distdir</code></dt>
  92. <dd><a name="index-distdir"></a>
  93. <a name="index-distdir-2"></a>
  94. <a name="index-top_005fdistdir-1"></a>
  95. <p>Copy files to distribute into &lsquo;<samp>$(distdir)</samp>&rsquo;, before a tarball is
  96. constructed. Of course this target is not required if the
  97. <samp>no-dist</samp> option (see <a href="Options.html#Options">Options</a>) is used.
  98. </p>
  99. <p>The variables &lsquo;<samp>$(top_distdir)</samp>&rsquo; and &lsquo;<samp>$(distdir)</samp>&rsquo;
  100. (see <a href="The-dist-Hook.html#The-dist-Hook">The dist Hook</a>) will be passed from the outer package to the subpackage
  101. when the <code>distdir</code> target is invoked. These two variables have
  102. been adjusted for the directory that is being recursed into, so they
  103. are ready to use.
  104. </p>
  105. </dd>
  106. <dt><code>install</code></dt>
  107. <dt><code>install-data</code></dt>
  108. <dt><code>install-exec</code></dt>
  109. <dt><code>uninstall</code></dt>
  110. <dd><p>Install or uninstall files (see <a href="Install.html#Install">Install</a>).
  111. </p>
  112. </dd>
  113. <dt><code>install-dvi</code></dt>
  114. <dt><code>install-html</code></dt>
  115. <dt><code>install-info</code></dt>
  116. <dt><code>install-ps</code></dt>
  117. <dt><code>install-pdf</code></dt>
  118. <dd><p>Install only some specific documentation format (see <a href="Texinfo.html#Texinfo">Texinfo</a>).
  119. </p>
  120. </dd>
  121. <dt><code>installdirs</code></dt>
  122. <dd><p>Create install directories, but do not install any files.
  123. </p>
  124. </dd>
  125. <dt><code>check</code></dt>
  126. <dt><code>installcheck</code></dt>
  127. <dd><p>Check the package (see <a href="Tests.html#Tests">Tests</a>).
  128. </p>
  129. </dd>
  130. <dt><code>mostlyclean</code></dt>
  131. <dt><code>clean</code></dt>
  132. <dt><code>distclean</code></dt>
  133. <dt><code>maintainer-clean</code></dt>
  134. <dd><p>Cleaning rules (see <a href="Clean.html#Clean">Clean</a>).
  135. </p>
  136. </dd>
  137. <dt><code>dvi</code></dt>
  138. <dt><code>pdf</code></dt>
  139. <dt><code>ps</code></dt>
  140. <dt><code>info</code></dt>
  141. <dt><code>html</code></dt>
  142. <dd><p>Build the documentation in various formats (see <a href="Texinfo.html#Texinfo">Texinfo</a>).
  143. </p>
  144. </dd>
  145. <dt><code>tags</code></dt>
  146. <dt><code>ctags</code></dt>
  147. <dd><p>Build <samp>TAGS</samp> and <samp>CTAGS</samp> (see <a href="Tags.html#Tags">Tags</a>).
  148. </p></dd>
  149. </dl>
  150. <p>If you have ever used Gettext in a project, this is a good example of
  151. how third-party <samp>Makefile</samp>s can be used with Automake. The
  152. <samp>Makefile</samp>s <code>gettextize</code> puts in the <samp>po/</samp> and
  153. <samp>intl/</samp> directories are handwritten <samp>Makefile</samp>s that
  154. implement all of these targets. That way they can be added to
  155. <code>SUBDIRS</code> in Automake packages.
  156. </p>
  157. <p>Directories that are only listed in <code>DIST_SUBDIRS</code> but not in
  158. <code>SUBDIRS</code> need only the <code>distclean</code>,
  159. <code>maintainer-clean</code>, and <code>distdir</code> rules (see <a href="Conditional-Subdirectories.html#Conditional-Subdirectories">Conditional Subdirectories</a>).
  160. </p>
  161. <p>Usually, many of these rules are irrelevant to the third-party
  162. subproject, but they are required for the whole package to work. It&rsquo;s
  163. OK to have a rule that does nothing, so if you are integrating a
  164. third-party project with no documentation or tag support, you could
  165. simply augment its <samp>Makefile</samp> as follows:
  166. </p>
  167. <div class="example">
  168. <pre class="example">EMPTY_AUTOMAKE_TARGETS = dvi pdf ps info html tags ctags
  169. .PHONY: $(EMPTY_AUTOMAKE_TARGETS)
  170. $(EMPTY_AUTOMAKE_TARGETS):
  171. </pre></div>
  172. <p>Another aspect of integrating third-party build systems is whether
  173. they support VPATH builds (see <a href="VPATH-Builds.html#VPATH-Builds">VPATH Builds</a>). Obviously if the
  174. subpackage does not support VPATH builds the whole package will not
  175. support VPATH builds. This in turns means that &lsquo;<samp>make distcheck</samp>&rsquo;
  176. will not work, because it relies on VPATH builds. Some people can
  177. live without this (actually, many Automake users have never heard of
  178. &lsquo;<samp>make distcheck</samp>&rsquo;). Other people may prefer to revamp the
  179. existing <samp>Makefile</samp>s to support VPATH. Doing so does not
  180. 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>).
  181. The necessary substitutions: &lsquo;<samp>@srcdir@</samp>&rsquo;, &lsquo;<samp>@top_srcdir@</samp>&rsquo;,
  182. and &lsquo;<samp>@top_builddir@</samp>&rsquo; are defined by <samp>configure</samp> when it
  183. 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
  184. Output Variables</a> in <cite>The Autoconf Manual</cite>), they are not
  185. computed by the Makefile like the aforementioned &lsquo;<samp>$(distdir)</samp>&rsquo; and
  186. &lsquo;<samp>$(top_distdir)</samp>&rsquo; variables.
  187. </p>
  188. <p>It is sometimes inconvenient to modify a third-party <samp>Makefile</samp>
  189. to introduce the above required targets. For instance, one may want to
  190. keep the third-party sources untouched to ease upgrades to new
  191. versions.
  192. </p>
  193. <a name="index-GNUmakefile-including-Makefile"></a>
  194. <p>Here are two other ideas. If GNU make is assumed, one possibility is
  195. to add to that subdirectory a <samp>GNUmakefile</samp> that defines the
  196. required targets and includes the third-party <samp>Makefile</samp>. For
  197. this to work in VPATH builds, <samp>GNUmakefile</samp> must lie in the build
  198. directory; the easiest way to do this is to write a
  199. <samp>GNUmakefile.in</samp> instead, and have it processed with
  200. <code>AC_CONFIG_FILES</code> from the outer package. For example if we
  201. assume <samp>Makefile</samp> defines all targets except the documentation
  202. targets, and that the <code>check</code> target is actually called
  203. <code>test</code>, we could write <samp>GNUmakefile</samp> (or
  204. <samp>GNUmakefile.in</samp>) like this:
  205. </p>
  206. <div class="example">
  207. <pre class="example"># First, include the real Makefile
  208. include Makefile
  209. # Then, define the other targets needed by Automake Makefiles.
  210. .PHONY: dvi pdf ps info html check
  211. dvi pdf ps info html:
  212. check: test
  213. </pre></div>
  214. <a name="index-Proxy-Makefile-for-third_002dparty-packages"></a>
  215. <p>A similar idea that does not use <code>include</code> is to write a proxy
  216. <samp>Makefile</samp> that dispatches rules to the real <samp>Makefile</samp>,
  217. either with &lsquo;<samp>$(MAKE) -f Makefile.real $(AM_MAKEFLAGS) target</samp>&rsquo; (if
  218. it&rsquo;s OK to rename the original <samp>Makefile</samp>) or with &lsquo;<samp>cd
  219. subdir &amp;&amp; $(MAKE) $(AM_MAKEFLAGS) target</samp>&rsquo; (if it&rsquo;s OK to store the
  220. subdirectory project one directory deeper). The good news is that
  221. this proxy <samp>Makefile</samp> can be generated with Automake. All we
  222. need are <samp>-local</samp> targets (see <a href="Extending.html#Extending">Extending</a>) that perform the
  223. dispatch. Of course the other Automake features are available, so you
  224. could decide to let Automake perform distribution or installation.
  225. Here is a possible <samp>Makefile.am</samp>:
  226. </p>
  227. <div class="example">
  228. <pre class="example">all-local:
  229. cd subdir &amp;&amp; $(MAKE) $(AM_MAKEFLAGS) all
  230. check-local:
  231. cd subdir &amp;&amp; $(MAKE) $(AM_MAKEFLAGS) test
  232. clean-local:
  233. cd subdir &amp;&amp; $(MAKE) $(AM_MAKEFLAGS) clean
  234. # Assuming the package knows how to install itself
  235. install-data-local:
  236. cd subdir &amp;&amp; $(MAKE) $(AM_MAKEFLAGS) install-data
  237. install-exec-local:
  238. cd subdir &amp;&amp; $(MAKE) $(AM_MAKEFLAGS) install-exec
  239. uninstall-local:
  240. cd subdir &amp;&amp; $(MAKE) $(AM_MAKEFLAGS) uninstall
  241. # Distribute files from here.
  242. EXTRA_DIST = subdir/Makefile subdir/program.c ...
  243. </pre></div>
  244. <p>Pushing this idea to the extreme, it is also possible to ignore the
  245. subproject build system and build everything from this proxy
  246. <samp>Makefile.am</samp>. This might sound very sensible if you need VPATH
  247. builds but the subproject does not support them.
  248. </p>
  249. <hr>
  250. <div class="header">
  251. <p>
  252. 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> &nbsp; [<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>
  253. </div>
  254. </body>
  255. </html>