makefile.texi 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. @c Copyright (C) 2001-2015 Free Software Foundation, Inc.
  2. @c This is part of the GCC manual.
  3. @c For copying conditions, see the file gcc.texi.
  4. @node Makefile
  5. @subsection Makefile Targets
  6. @cindex makefile targets
  7. @cindex targets, makefile
  8. These targets are available from the @samp{gcc} directory:
  9. @table @code
  10. @item all
  11. This is the default target. Depending on what your build/host/target
  12. configuration is, it coordinates all the things that need to be built.
  13. @item doc
  14. Produce info-formatted documentation and man pages. Essentially it
  15. calls @samp{make man} and @samp{make info}.
  16. @item dvi
  17. Produce DVI-formatted documentation.
  18. @item pdf
  19. Produce PDF-formatted documentation.
  20. @item html
  21. Produce HTML-formatted documentation.
  22. @item man
  23. Generate man pages.
  24. @item info
  25. Generate info-formatted pages.
  26. @item mostlyclean
  27. Delete the files made while building the compiler.
  28. @item clean
  29. That, and all the other files built by @samp{make all}.
  30. @item distclean
  31. That, and all the files created by @command{configure}.
  32. @item maintainer-clean
  33. Distclean plus any file that can be generated from other files. Note
  34. that additional tools may be required beyond what is normally needed to
  35. build GCC.
  36. @item srcextra
  37. Generates files in the source directory that are not version-controlled but
  38. should go into a release tarball.
  39. @item srcinfo
  40. @itemx srcman
  41. Copies the info-formatted and manpage documentation into the source
  42. directory usually for the purpose of generating a release tarball.
  43. @item install
  44. Installs GCC.
  45. @item uninstall
  46. Deletes installed files, though this is not supported.
  47. @item check
  48. Run the testsuite. This creates a @file{testsuite} subdirectory that
  49. has various @file{.sum} and @file{.log} files containing the results of
  50. the testing. You can run subsets with, for example, @samp{make check-gcc}.
  51. You can specify specific tests by setting @env{RUNTESTFLAGS} to be the name
  52. of the @file{.exp} file, optionally followed by (for some tests) an equals
  53. and a file wildcard, like:
  54. @smallexample
  55. make check-gcc RUNTESTFLAGS="execute.exp=19980413-*"
  56. @end smallexample
  57. Note that running the testsuite may require additional tools be
  58. installed, such as Tcl or DejaGnu.
  59. @end table
  60. The toplevel tree from which you start GCC compilation is not
  61. the GCC directory, but rather a complex Makefile that coordinates
  62. the various steps of the build, including bootstrapping the compiler
  63. and using the new compiler to build target libraries.
  64. When GCC is configured for a native configuration, the default action
  65. for @command{make} is to do a full three-stage bootstrap. This means
  66. that GCC is built three times---once with the native compiler, once with
  67. the native-built compiler it just built, and once with the compiler it
  68. built the second time. In theory, the last two should produce the same
  69. results, which @samp{make compare} can check. Each stage is configured
  70. separately and compiled into a separate directory, to minimize problems
  71. due to ABI incompatibilities between the native compiler and GCC.
  72. If you do a change, rebuilding will also start from the first stage
  73. and ``bubble'' up the change through the three stages. Each stage
  74. is taken from its build directory (if it had been built previously),
  75. rebuilt, and copied to its subdirectory. This will allow you to, for
  76. example, continue a bootstrap after fixing a bug which causes the
  77. stage2 build to crash. It does not provide as good coverage of the
  78. compiler as bootstrapping from scratch, but it ensures that the new
  79. code is syntactically correct (e.g., that you did not use GCC extensions
  80. by mistake), and avoids spurious bootstrap comparison
  81. failures@footnote{Except if the compiler was buggy and miscompiled
  82. some of the files that were not modified. In this case, it's best
  83. to use @command{make restrap}.}.
  84. Other targets available from the top level include:
  85. @table @code
  86. @item bootstrap-lean
  87. Like @code{bootstrap}, except that the various stages are removed once
  88. they're no longer needed. This saves disk space.
  89. @item bootstrap2
  90. @itemx bootstrap2-lean
  91. Performs only the first two stages of bootstrap. Unlike a three-stage
  92. bootstrap, this does not perform a comparison to test that the compiler
  93. is running properly. Note that the disk space required by a ``lean''
  94. bootstrap is approximately independent of the number of stages.
  95. @item stage@var{N}-bubble (@var{N} = 1@dots{}4, profile, feedback)
  96. Rebuild all the stages up to @var{N}, with the appropriate flags,
  97. ``bubbling'' the changes as described above.
  98. @item all-stage@var{N} (@var{N} = 1@dots{}4, profile, feedback)
  99. Assuming that stage @var{N} has already been built, rebuild it with the
  100. appropriate flags. This is rarely needed.
  101. @item cleanstrap
  102. Remove everything (@samp{make clean}) and rebuilds (@samp{make bootstrap}).
  103. @item compare
  104. Compares the results of stages 2 and 3. This ensures that the compiler
  105. is running properly, since it should produce the same object files
  106. regardless of how it itself was compiled.
  107. @item profiledbootstrap
  108. Builds a compiler with profiling feedback information. In this case,
  109. the second and third stages are named @samp{profile} and @samp{feedback},
  110. respectively. For more information, see
  111. @ref{Building,,Building with profile feedback,gccinstall,Installing GCC}.
  112. @item restrap
  113. Restart a bootstrap, so that everything that was not built with
  114. the system compiler is rebuilt.
  115. @item stage@var{N}-start (@var{N} = 1@dots{}4, profile, feedback)
  116. For each package that is bootstrapped, rename directories so that,
  117. for example, @file{gcc} points to the stage@var{N} GCC, compiled
  118. with the stage@var{N-1} GCC@footnote{Customarily, the system compiler
  119. is also termed the @file{stage0} GCC.}.
  120. You will invoke this target if you need to test or debug the
  121. stage@var{N} GCC@. If you only need to execute GCC (but you need
  122. not run @samp{make} either to rebuild it or to run test suites),
  123. you should be able to work directly in the @file{stage@var{N}-gcc}
  124. directory. This makes it easier to debug multiple stages in
  125. parallel.
  126. @item stage
  127. For each package that is bootstrapped, relocate its build directory
  128. to indicate its stage. For example, if the @file{gcc} directory
  129. points to the stage2 GCC, after invoking this target it will be
  130. renamed to @file{stage2-gcc}.
  131. @end table
  132. If you wish to use non-default GCC flags when compiling the stage2 and
  133. stage3 compilers, set @code{BOOT_CFLAGS} on the command line when doing
  134. @samp{make}.
  135. Usually, the first stage only builds the languages that the compiler
  136. is written in: typically, C and maybe Ada. If you are debugging a
  137. miscompilation of a different stage2 front-end (for example, of the
  138. Fortran front-end), you may want to have front-ends for other languages
  139. in the first stage as well. To do so, set @code{STAGE1_LANGUAGES}
  140. on the command line when doing @samp{make}.
  141. For example, in the aforementioned scenario of debugging a Fortran
  142. front-end miscompilation caused by the stage1 compiler, you may need a
  143. command like
  144. @example
  145. make stage2-bubble STAGE1_LANGUAGES=c,fortran
  146. @end example
  147. Alternatively, you can use per-language targets to build and test
  148. languages that are not enabled by default in stage1. For example,
  149. @command{make f951} will build a Fortran compiler even in the stage1
  150. build directory.