1*ec02198aSmrg@c Copyright (C) 2001-2020 Free Software Foundation, Inc.
210d565efSmrg@c This is part of the GCC manual.
310d565efSmrg@c For copying conditions, see the file gcc.texi.
410d565efSmrg
510d565efSmrg@node Makefile
610d565efSmrg@subsection Makefile Targets
710d565efSmrg@cindex makefile targets
810d565efSmrg@cindex targets, makefile
910d565efSmrg
1010d565efSmrgThese targets are available from the @samp{gcc} directory:
1110d565efSmrg
1210d565efSmrg@table @code
1310d565efSmrg@item all
1410d565efSmrgThis is the default target.  Depending on what your build/host/target
1510d565efSmrgconfiguration is, it coordinates all the things that need to be built.
1610d565efSmrg
1710d565efSmrg@item doc
1810d565efSmrgProduce info-formatted documentation and man pages.  Essentially it
1910d565efSmrgcalls @samp{make man} and @samp{make info}.
2010d565efSmrg
2110d565efSmrg@item dvi
2210d565efSmrgProduce DVI-formatted documentation.
2310d565efSmrg
2410d565efSmrg@item pdf
2510d565efSmrgProduce PDF-formatted documentation.
2610d565efSmrg
2710d565efSmrg@item html
2810d565efSmrgProduce HTML-formatted documentation.
2910d565efSmrg
3010d565efSmrg@item man
3110d565efSmrgGenerate man pages.
3210d565efSmrg
3310d565efSmrg@item info
3410d565efSmrgGenerate info-formatted pages.
3510d565efSmrg
3610d565efSmrg@item mostlyclean
3710d565efSmrgDelete the files made while building the compiler.
3810d565efSmrg
3910d565efSmrg@item clean
4010d565efSmrgThat, and all the other files built by @samp{make all}.
4110d565efSmrg
4210d565efSmrg@item distclean
4310d565efSmrgThat, and all the files created by @command{configure}.
4410d565efSmrg
4510d565efSmrg@item maintainer-clean
4610d565efSmrgDistclean plus any file that can be generated from other files.  Note
4710d565efSmrgthat additional tools may be required beyond what is normally needed to
4810d565efSmrgbuild GCC.
4910d565efSmrg
5010d565efSmrg@item srcextra
5110d565efSmrgGenerates files in the source directory that are not version-controlled but
5210d565efSmrgshould go into a release tarball.
5310d565efSmrg
5410d565efSmrg@item srcinfo
5510d565efSmrg@itemx srcman
5610d565efSmrgCopies the info-formatted and manpage documentation into the source
5710d565efSmrgdirectory usually for the purpose of generating a release tarball.
5810d565efSmrg
5910d565efSmrg@item install
6010d565efSmrgInstalls GCC.
6110d565efSmrg
6210d565efSmrg@item uninstall
6310d565efSmrgDeletes installed files, though this is not supported.
6410d565efSmrg
6510d565efSmrg@item check
6610d565efSmrgRun the testsuite.  This creates a @file{testsuite} subdirectory that
6710d565efSmrghas various @file{.sum} and @file{.log} files containing the results of
6810d565efSmrgthe testing.  You can run subsets with, for example, @samp{make check-gcc}.
6910d565efSmrgYou can specify specific tests by setting @env{RUNTESTFLAGS} to be the name
7010d565efSmrgof the @file{.exp} file, optionally followed by (for some tests) an equals
7110d565efSmrgand a file wildcard, like:
7210d565efSmrg
7310d565efSmrg@smallexample
7410d565efSmrgmake check-gcc RUNTESTFLAGS="execute.exp=19980413-*"
7510d565efSmrg@end smallexample
7610d565efSmrg
7710d565efSmrgNote that running the testsuite may require additional tools be
7810d565efSmrginstalled, such as Tcl or DejaGnu.
7910d565efSmrg@end table
8010d565efSmrg
8110d565efSmrgThe toplevel tree from which you start GCC compilation is not
8210d565efSmrgthe GCC directory, but rather a complex Makefile that coordinates
8310d565efSmrgthe various steps of the build, including bootstrapping the compiler
8410d565efSmrgand using the new compiler to build target libraries.
8510d565efSmrg
8610d565efSmrgWhen GCC is configured for a native configuration, the default action
8710d565efSmrgfor @command{make} is to do a full three-stage bootstrap.  This means
8810d565efSmrgthat GCC is built three times---once with the native compiler, once with
8910d565efSmrgthe native-built compiler it just built, and once with the compiler it
9010d565efSmrgbuilt the second time.  In theory, the last two should produce the same
9110d565efSmrgresults, which @samp{make compare} can check.  Each stage is configured
9210d565efSmrgseparately and compiled into a separate directory, to minimize problems
9310d565efSmrgdue to ABI incompatibilities between the native compiler and GCC.
9410d565efSmrg
9510d565efSmrgIf you do a change, rebuilding will also start from the first stage
9610d565efSmrgand ``bubble'' up the change through the three stages.  Each stage
9710d565efSmrgis taken from its build directory (if it had been built previously),
9810d565efSmrgrebuilt, and copied to its subdirectory.  This will allow you to, for
9910d565efSmrgexample, continue a bootstrap after fixing a bug which causes the
10010d565efSmrgstage2 build to crash.  It does not provide as good coverage of the
10110d565efSmrgcompiler as bootstrapping from scratch, but it ensures that the new
10210d565efSmrgcode is syntactically correct (e.g., that you did not use GCC extensions
10310d565efSmrgby mistake), and avoids spurious bootstrap comparison
10410d565efSmrgfailures@footnote{Except if the compiler was buggy and miscompiled
10510d565efSmrgsome of the files that were not modified.  In this case, it's best
10610d565efSmrgto use @command{make restrap}.}.
10710d565efSmrg
10810d565efSmrgOther targets available from the top level include:
10910d565efSmrg
11010d565efSmrg@table @code
11110d565efSmrg@item bootstrap-lean
11210d565efSmrgLike @code{bootstrap}, except that the various stages are removed once
11310d565efSmrgthey're no longer needed.  This saves disk space.
11410d565efSmrg
11510d565efSmrg@item bootstrap2
11610d565efSmrg@itemx bootstrap2-lean
11710d565efSmrgPerforms only the first two stages of bootstrap.  Unlike a three-stage
11810d565efSmrgbootstrap, this does not perform a comparison to test that the compiler
11910d565efSmrgis running properly.  Note that the disk space required by a ``lean''
12010d565efSmrgbootstrap is approximately independent of the number of stages.
12110d565efSmrg
12210d565efSmrg@item stage@var{N}-bubble (@var{N} = 1@dots{}4, profile, feedback)
12310d565efSmrgRebuild all the stages up to @var{N}, with the appropriate flags,
12410d565efSmrg``bubbling'' the changes as described above.
12510d565efSmrg
12610d565efSmrg@item all-stage@var{N} (@var{N} = 1@dots{}4, profile, feedback)
12710d565efSmrgAssuming that stage @var{N} has already been built, rebuild it with the
12810d565efSmrgappropriate flags.  This is rarely needed.
12910d565efSmrg
13010d565efSmrg@item cleanstrap
13110d565efSmrgRemove everything (@samp{make clean}) and rebuilds (@samp{make bootstrap}).
13210d565efSmrg
13310d565efSmrg@item compare
13410d565efSmrgCompares the results of stages 2 and 3.  This ensures that the compiler
13510d565efSmrgis running properly, since it should produce the same object files
13610d565efSmrgregardless of how it itself was compiled.
13710d565efSmrg
13810d565efSmrg@item profiledbootstrap
13910d565efSmrgBuilds a compiler with profiling feedback information.  In this case,
14010d565efSmrgthe second and third stages are named @samp{profile} and @samp{feedback},
14110d565efSmrgrespectively.  For more information, see the installation instructions.
14210d565efSmrg
14310d565efSmrg@item restrap
14410d565efSmrgRestart a bootstrap, so that everything that was not built with
14510d565efSmrgthe system compiler is rebuilt.
14610d565efSmrg
14710d565efSmrg@item stage@var{N}-start (@var{N} = 1@dots{}4, profile, feedback)
14810d565efSmrgFor each package that is bootstrapped, rename directories so that,
14910d565efSmrgfor example, @file{gcc} points to the stage@var{N} GCC, compiled
15010d565efSmrgwith the stage@var{N-1} GCC@footnote{Customarily, the system compiler
15110d565efSmrgis also termed the @file{stage0} GCC.}.
15210d565efSmrg
15310d565efSmrgYou will invoke this target if you need to test or debug the
15410d565efSmrgstage@var{N} GCC@.  If you only need to execute GCC (but you need
15510d565efSmrgnot run @samp{make} either to rebuild it or to run test suites),
15610d565efSmrgyou should be able to work directly in the @file{stage@var{N}-gcc}
15710d565efSmrgdirectory.  This makes it easier to debug multiple stages in
15810d565efSmrgparallel.
15910d565efSmrg
16010d565efSmrg@item stage
16110d565efSmrgFor each package that is bootstrapped, relocate its build directory
16210d565efSmrgto indicate its stage.  For example, if the @file{gcc} directory
16310d565efSmrgpoints to the stage2 GCC, after invoking this target it will be
16410d565efSmrgrenamed to @file{stage2-gcc}.
16510d565efSmrg
16610d565efSmrg@end table
16710d565efSmrg
16810d565efSmrgIf you wish to use non-default GCC flags when compiling the stage2 and
16910d565efSmrgstage3 compilers, set @code{BOOT_CFLAGS} on the command line when doing
17010d565efSmrg@samp{make}.
17110d565efSmrg
17210d565efSmrgUsually, the first stage only builds the languages that the compiler
17310d565efSmrgis written in: typically, C and maybe Ada.  If you are debugging a
17410d565efSmrgmiscompilation of a different stage2 front-end (for example, of the
17510d565efSmrgFortran front-end), you may want to have front-ends for other languages
17610d565efSmrgin the first stage as well.  To do so, set @code{STAGE1_LANGUAGES}
17710d565efSmrgon the command line when doing @samp{make}.
17810d565efSmrg
17910d565efSmrgFor example, in the aforementioned scenario of debugging a Fortran
18010d565efSmrgfront-end miscompilation caused by the stage1 compiler, you may need a
18110d565efSmrgcommand like
18210d565efSmrg
18310d565efSmrg@example
18410d565efSmrgmake stage2-bubble STAGE1_LANGUAGES=c,fortran
18510d565efSmrg@end example
18610d565efSmrg
18710d565efSmrgAlternatively, you can use per-language targets to build and test
18810d565efSmrglanguages that are not enabled by default in stage1.  For example,
18910d565efSmrg@command{make f951} will build a Fortran compiler even in the stage1
19010d565efSmrgbuild directory.
19110d565efSmrg
192