Makefile.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2017 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>GNU Compiler Collection (GCC) Internals: Makefile</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Makefile">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Makefile">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="gcc-Directory.html#gcc-Directory" rel="up" title="gcc Directory">
  30. <link href="Library-Files.html#Library-Files" rel="next" title="Library Files">
  31. <link href="Build.html#Build" rel="prev" title="Build">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style:oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="Makefile"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Library-Files.html#Library-Files" accesskey="n" rel="next">Library Files</a>, Previous: <a href="Build.html#Build" accesskey="p" rel="prev">Build</a>, Up: <a href="gcc-Directory.html#gcc-Directory" accesskey="u" rel="up">gcc Directory</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  66. </div>
  67. <hr>
  68. <a name="Makefile-Targets"></a>
  69. <h4 class="subsection">6.3.4 Makefile Targets</h4>
  70. <a name="index-makefile-targets"></a>
  71. <a name="index-targets_002c-makefile"></a>
  72. <p>These targets are available from the &lsquo;<samp>gcc</samp>&rsquo; directory:
  73. </p>
  74. <dl compact="compact">
  75. <dt><code>all</code></dt>
  76. <dd><p>This is the default target. Depending on what your build/host/target
  77. configuration is, it coordinates all the things that need to be built.
  78. </p>
  79. </dd>
  80. <dt><code>doc</code></dt>
  81. <dd><p>Produce info-formatted documentation and man pages. Essentially it
  82. calls &lsquo;<samp>make man</samp>&rsquo; and &lsquo;<samp>make info</samp>&rsquo;.
  83. </p>
  84. </dd>
  85. <dt><code>dvi</code></dt>
  86. <dd><p>Produce DVI-formatted documentation.
  87. </p>
  88. </dd>
  89. <dt><code>pdf</code></dt>
  90. <dd><p>Produce PDF-formatted documentation.
  91. </p>
  92. </dd>
  93. <dt><code>html</code></dt>
  94. <dd><p>Produce HTML-formatted documentation.
  95. </p>
  96. </dd>
  97. <dt><code>man</code></dt>
  98. <dd><p>Generate man pages.
  99. </p>
  100. </dd>
  101. <dt><code>info</code></dt>
  102. <dd><p>Generate info-formatted pages.
  103. </p>
  104. </dd>
  105. <dt><code>mostlyclean</code></dt>
  106. <dd><p>Delete the files made while building the compiler.
  107. </p>
  108. </dd>
  109. <dt><code>clean</code></dt>
  110. <dd><p>That, and all the other files built by &lsquo;<samp>make all</samp>&rsquo;.
  111. </p>
  112. </dd>
  113. <dt><code>distclean</code></dt>
  114. <dd><p>That, and all the files created by <code>configure</code>.
  115. </p>
  116. </dd>
  117. <dt><code>maintainer-clean</code></dt>
  118. <dd><p>Distclean plus any file that can be generated from other files. Note
  119. that additional tools may be required beyond what is normally needed to
  120. build GCC.
  121. </p>
  122. </dd>
  123. <dt><code>srcextra</code></dt>
  124. <dd><p>Generates files in the source directory that are not version-controlled but
  125. should go into a release tarball.
  126. </p>
  127. </dd>
  128. <dt><code>srcinfo</code></dt>
  129. <dt><code>srcman</code></dt>
  130. <dd><p>Copies the info-formatted and manpage documentation into the source
  131. directory usually for the purpose of generating a release tarball.
  132. </p>
  133. </dd>
  134. <dt><code>install</code></dt>
  135. <dd><p>Installs GCC.
  136. </p>
  137. </dd>
  138. <dt><code>uninstall</code></dt>
  139. <dd><p>Deletes installed files, though this is not supported.
  140. </p>
  141. </dd>
  142. <dt><code>check</code></dt>
  143. <dd><p>Run the testsuite. This creates a <samp>testsuite</samp> subdirectory that
  144. has various <samp>.sum</samp> and <samp>.log</samp> files containing the results of
  145. the testing. You can run subsets with, for example, &lsquo;<samp>make check-gcc</samp>&rsquo;.
  146. You can specify specific tests by setting <code>RUNTESTFLAGS</code> to be the name
  147. of the <samp>.exp</samp> file, optionally followed by (for some tests) an equals
  148. and a file wildcard, like:
  149. </p>
  150. <div class="smallexample">
  151. <pre class="smallexample">make check-gcc RUNTESTFLAGS=&quot;execute.exp=19980413-*&quot;
  152. </pre></div>
  153. <p>Note that running the testsuite may require additional tools be
  154. installed, such as Tcl or DejaGnu.
  155. </p></dd>
  156. </dl>
  157. <p>The toplevel tree from which you start GCC compilation is not
  158. the GCC directory, but rather a complex Makefile that coordinates
  159. the various steps of the build, including bootstrapping the compiler
  160. and using the new compiler to build target libraries.
  161. </p>
  162. <p>When GCC is configured for a native configuration, the default action
  163. for <code>make</code> is to do a full three-stage bootstrap. This means
  164. that GCC is built three times&mdash;once with the native compiler, once with
  165. the native-built compiler it just built, and once with the compiler it
  166. built the second time. In theory, the last two should produce the same
  167. results, which &lsquo;<samp>make compare</samp>&rsquo; can check. Each stage is configured
  168. separately and compiled into a separate directory, to minimize problems
  169. due to ABI incompatibilities between the native compiler and GCC.
  170. </p>
  171. <p>If you do a change, rebuilding will also start from the first stage
  172. and &ldquo;bubble&rdquo; up the change through the three stages. Each stage
  173. is taken from its build directory (if it had been built previously),
  174. rebuilt, and copied to its subdirectory. This will allow you to, for
  175. example, continue a bootstrap after fixing a bug which causes the
  176. stage2 build to crash. It does not provide as good coverage of the
  177. compiler as bootstrapping from scratch, but it ensures that the new
  178. code is syntactically correct (e.g., that you did not use GCC extensions
  179. by mistake), and avoids spurious bootstrap comparison
  180. failures<a name="DOCF1" href="#FOOT1"><sup>1</sup></a>.
  181. </p>
  182. <p>Other targets available from the top level include:
  183. </p>
  184. <dl compact="compact">
  185. <dt><code>bootstrap-lean</code></dt>
  186. <dd><p>Like <code>bootstrap</code>, except that the various stages are removed once
  187. they&rsquo;re no longer needed. This saves disk space.
  188. </p>
  189. </dd>
  190. <dt><code>bootstrap2</code></dt>
  191. <dt><code>bootstrap2-lean</code></dt>
  192. <dd><p>Performs only the first two stages of bootstrap. Unlike a three-stage
  193. bootstrap, this does not perform a comparison to test that the compiler
  194. is running properly. Note that the disk space required by a &ldquo;lean&rdquo;
  195. bootstrap is approximately independent of the number of stages.
  196. </p>
  197. </dd>
  198. <dt><code>stage<var>N</var>-bubble (<var>N</var> = 1&hellip;4, profile, feedback)</code></dt>
  199. <dd><p>Rebuild all the stages up to <var>N</var>, with the appropriate flags,
  200. &ldquo;bubbling&rdquo; the changes as described above.
  201. </p>
  202. </dd>
  203. <dt><code>all-stage<var>N</var> (<var>N</var> = 1&hellip;4, profile, feedback)</code></dt>
  204. <dd><p>Assuming that stage <var>N</var> has already been built, rebuild it with the
  205. appropriate flags. This is rarely needed.
  206. </p>
  207. </dd>
  208. <dt><code>cleanstrap</code></dt>
  209. <dd><p>Remove everything (&lsquo;<samp>make clean</samp>&rsquo;) and rebuilds (&lsquo;<samp>make bootstrap</samp>&rsquo;).
  210. </p>
  211. </dd>
  212. <dt><code>compare</code></dt>
  213. <dd><p>Compares the results of stages 2 and 3. This ensures that the compiler
  214. is running properly, since it should produce the same object files
  215. regardless of how it itself was compiled.
  216. </p>
  217. </dd>
  218. <dt><code>profiledbootstrap</code></dt>
  219. <dd><p>Builds a compiler with profiling feedback information. In this case,
  220. the second and third stages are named &lsquo;<samp>profile</samp>&rsquo; and &lsquo;<samp>feedback</samp>&rsquo;,
  221. respectively. For more information, see the installation instructions.
  222. </p>
  223. </dd>
  224. <dt><code>restrap</code></dt>
  225. <dd><p>Restart a bootstrap, so that everything that was not built with
  226. the system compiler is rebuilt.
  227. </p>
  228. </dd>
  229. <dt><code>stage<var>N</var>-start (<var>N</var> = 1&hellip;4, profile, feedback)</code></dt>
  230. <dd><p>For each package that is bootstrapped, rename directories so that,
  231. for example, <samp>gcc</samp> points to the stage<var>N</var> GCC, compiled
  232. with the stage<var>N-1</var> GCC<a name="DOCF2" href="#FOOT2"><sup>2</sup></a>.
  233. </p>
  234. <p>You will invoke this target if you need to test or debug the
  235. stage<var>N</var> GCC. If you only need to execute GCC (but you need
  236. not run &lsquo;<samp>make</samp>&rsquo; either to rebuild it or to run test suites),
  237. you should be able to work directly in the <samp>stage<var>N</var>-gcc</samp>
  238. directory. This makes it easier to debug multiple stages in
  239. parallel.
  240. </p>
  241. </dd>
  242. <dt><code>stage</code></dt>
  243. <dd><p>For each package that is bootstrapped, relocate its build directory
  244. to indicate its stage. For example, if the <samp>gcc</samp> directory
  245. points to the stage2 GCC, after invoking this target it will be
  246. renamed to <samp>stage2-gcc</samp>.
  247. </p>
  248. </dd>
  249. </dl>
  250. <p>If you wish to use non-default GCC flags when compiling the stage2 and
  251. stage3 compilers, set <code>BOOT_CFLAGS</code> on the command line when doing
  252. &lsquo;<samp>make</samp>&rsquo;.
  253. </p>
  254. <p>Usually, the first stage only builds the languages that the compiler
  255. is written in: typically, C and maybe Ada. If you are debugging a
  256. miscompilation of a different stage2 front-end (for example, of the
  257. Fortran front-end), you may want to have front-ends for other languages
  258. in the first stage as well. To do so, set <code>STAGE1_LANGUAGES</code>
  259. on the command line when doing &lsquo;<samp>make</samp>&rsquo;.
  260. </p>
  261. <p>For example, in the aforementioned scenario of debugging a Fortran
  262. front-end miscompilation caused by the stage1 compiler, you may need a
  263. command like
  264. </p>
  265. <div class="example">
  266. <pre class="example">make stage2-bubble STAGE1_LANGUAGES=c,fortran
  267. </pre></div>
  268. <p>Alternatively, you can use per-language targets to build and test
  269. languages that are not enabled by default in stage1. For example,
  270. <code>make f951</code> will build a Fortran compiler even in the stage1
  271. build directory.
  272. </p>
  273. <div class="footnote">
  274. <hr>
  275. <h4 class="footnotes-heading">Footnotes</h4>
  276. <h3><a name="FOOT1" href="#DOCF1">(1)</a></h3>
  277. <p>Except if the compiler was buggy and miscompiled
  278. some of the files that were not modified. In this case, it&rsquo;s best
  279. to use <code>make restrap</code>.</p>
  280. <h3><a name="FOOT2" href="#DOCF2">(2)</a></h3>
  281. <p>Customarily, the system compiler
  282. is also termed the <samp>stage0</samp> GCC.</p>
  283. </div>
  284. <hr>
  285. <div class="header">
  286. <p>
  287. Next: <a href="Library-Files.html#Library-Files" accesskey="n" rel="next">Library Files</a>, Previous: <a href="Build.html#Build" accesskey="p" rel="prev">Build</a>, Up: <a href="gcc-Directory.html#gcc-Directory" accesskey="u" rel="up">gcc Directory</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  288. </div>
  289. </body>
  290. </html>