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