1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00
llvm-mirror/docs/MakefileGuide.html
Chris Lattner 372d243311 Fix spellos
llvm-svn: 17224
2004-10-25 19:28:03 +00:00

516 lines
24 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>LLVM Makefile Guide</title>
<link rel="stylesheet" href="llvm.css" type="text/css">
</head>
<body>
<div class="doc_title">LLVM Makefile Guide</div>
<ol>
<li><a href="#introduction">Introduction</a></li>
<li><a href="#general">General Concepts</a>
<ol>
<li><a href="#projects">Projects</a></li>
<li><a href="#Makefile">Makefile</a></li>
<li><a href="#Makefile.common">Makefile.common</a></li>
<li><a href="#Makefile.config">Makefile.config</a></li>
<li><a href="#Makefile.rules">Makefile.rules</a></li>
<li><a href="#Comments">Comments</a></li>
</ol>
</li>
<li><a href="#targets">Targets Supported</a>
<ol>
<li><a href="#all">all</a></li>
<li><a href="#all-local">all-local</a></li>
<li><a href="#check">check</a></li>
<li><a href="#check-local">check-local</a></li>
<li><a href="#clean">clean</a></li>
<li><a href="#clean-local">clean-local</a></li>
<li><a href="#dist">dist</a></li>
<li><a href="#dist-check">dist-check</a></li>
<li><a href="#dist-clean">dist-clean</a></li>
<li><a href="#install">install</a></li>
<li><a href="#printvars">printvars</a></li>
<li><a href="#tags">tags</a></li>
<li><a href="#uninstall">uninstall</a></li>
</ol>
</li>
<li><a href="#variables">Using Variables</a>
<ol>
<li><a href="#setvars">Control Variables</a></li>
<li><a href="#overvars">Override Variables</a></li>
<li><a href="#getvars">Readable Variables</a></li>
</ol>
</li>
</ol>
<div class="doc_author">
<p>Written by <a href="mailto:reid@x10sys.com">Reid Spencer</a></p>
</div>
<div class="doc_warning"><p>WARNING: This document is a work in progress!</p></div>
<!-- *********************************************************************** -->
<div class="doc_section"><a name="introduction">Introduction </a></div>
<!-- *********************************************************************** -->
<div class="doc_text">
<p>This document provides <em>usage</em> information about the LLVM makefile
system. While loosely patterned after the BSD makefile system, LLVM has taken
a departure from BSD in order to implement additional features needed by LLVM.
</p>
<p>Although makefile systems such as automake were attempted at one point, it
has become clear that the variations required by LLVM from any Makefile norm
are too many to strictly use a more limited tool. Consequently, LLVM requires
simply GNU Make 3.79, a widely portably makefile processor. LLVM unabashedly
makes heavy use of the features of GNU Make so the dependency on GNU Make is
firm. If you're not familiar with <tt>make</tt>, it is recommended that you
read the <a href="http://www.gnu.org/software/make/manual/make.html">
GNU Makefile Manual</a>.</p>
<p>While this document is rightly part of the
<a href="ProgrammersManual.html">LLVM Programmer's Manual</a>, it is treated
separately here because of the volume of content and because it is often an
early source of bewilderment for new developers.</p>
</div>
<!-- *********************************************************************** -->
<div class="doc_section"><a name="general">General Concepts</a></div>
<!-- *********************************************************************** -->
<div class="doc_text">
<p>The LLVM makefile system is the component of LLVM that is responsible for
building the software, testing it, generating distributions, rpms and other
packages, installing and uninstalling, etc.</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="projects">Projects</a></div>
<div class="doc_text">
<p>The LLVM Makefile System is quite generous. It not only builds its own
software, but it can build yours too. Built into the system is knowledge of
the <tt>llvm/projects</tt> directory. Any directory under <tt>projects</tt>
that has both a <tt>configure</tt> script and a <tt>Makefile</tt> is assumed
to be a project that uses the LLVM Makefile system. This allows your project
to get up and running quickly by utilizing the built-in features that are used
to compile LLVM.</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="Makefile">Makefile</a></div>
<div class="doc_text">
<p>Each directory to participate in the build needs to have a file named
<tt>Makefile</tt>. This is the file first read by <tt>make</tt>. It has three
sections:</p>
<ol>
<li><a href="setvars">Settable Variables</a> - Required that must be set
first.</li>
<li><a href="Makefile.common">include <tt>$(LEVEL)/Makefile.common</tt></a>
- include the LLVM Makefile system.
<li><a href="overvars">Overridable Variables</a> - Override variables set by
the LLVM Makefile system.
</ol>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="Makefile.common">Makefile.common</a></div>
<div class="doc_text">
<p>Every project must have a <tt>Makefile.common</tt> file at its top source
directory. This file serves three purposes:</p>
<ol>
<li>It includes the project's configuration makefile to obtain values
determined by the <tt>configure</tt> script. This is done by including the
<a href="Makefile.config"><tt>$(LEVEL)/Makefile.config</tt></a> file.</li>
<li>It specifies any other (static) values that are needed throughout the
project. Only values that are used in all or a large proportion of the
project's directories should be placed here.</li>
<li>It include's the standard rules for the LLVM Makefile system,
<a href="Makefile.rules"><tt>$(LLVM_SRC_ROOT)/Makefile.rules</tt></a>.
This file is the "guts" of the LLVM Makefile system.</li>
</ol>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="Makefile.config">Makefile.config</a></div>
<div class="doc_text">
<p>Every project must have a <tt>Makefile.config</tt> at the top of its
<em>build</em> directory. This file is <b>generated</b> by the
<tt>configure</tt> script from the pattern provided by the
<tt>Makefile.config.in</tt> file located at the top of the project's
<em>source</em> directory. The contents of this file depend largely on what
configuration items the project uses, however most projects can get what they
need by just relying on LLVM's configuration found in
<tt>$(LLVM_OBJ_ROOT)/Makefile.config</tt>.
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="Makefile.rules">Makefile.rules</a></div>
<div class="doc_text">
<p>This file, located at <tt>$(LLVM_SRC_ROOT)/Makefile.rules</tt> is the heart
of the LLVM Makefile System. It provides all the logic, dependencies, and
rules for building the targets supported by the system. What it does largely
depends on the values of <tt>make</tt> <a href="variables">variables</a> that
have been set <em>before</em> <tt>Makefile.rules</tt> is included.
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="Comments">Comments</a></div>
<div class="doc_text">
<p>User Makefiles need not have comments in them unless the construction is
unusual or it doesn't strictly follow the rules and patterns of the LLVM
makefile system. Makefile comments are invoked with the pound (#) character.
The # character and any text following it, to the end of the line, are ignored
by <tt>make</tt>.</p>
</div>
<!-- *********************************************************************** -->
<div class="doc_section"><a name="targets">Targets Supported</a></div>
<!-- *********************************************************************** -->
<div class="doc_text">
<p>This section describes each of the targets that can be built using the LLVM
Makefile system. Any target can be invoked from any directory but not all are
applicable to a given directory (e.g. "dist" and "install" will always operate
as if invoked from the top level directory).</p>
<table style="text-align:left">
<tr><th>Target Name</th><th>Implied Targets</th><th>Target Description</th></tr>
<tr><td><a href="#all"><tt>all</tt></a></td><td></td>
<td>Compile the software recursively. Default target.
</td></tr>
<tr><td><a href="#all-local"><tt>all-local</tt></a></td><td></td>
<td>Compile the software in the local directory only.
</td></tr>
<tr><td><a href="#check"><tt>check</tt></a></td><td>all</td>
<td>Test the software recursively.
</td></tr>
<tr><td><a href="#check-local"><tt>check-local</tt></a></td><td>all-local</td>
<td>Test the software in the local directory only.
</td></tr>
<tr><td><a href="#clean"><tt>clean</tt></a></td><td></td>
<td>Remove built objects recursively.
</td></tr>
<tr><td><a href="#clean-local"><tt>clean-local</tt></a></td><td></td>
<td>Remove built objects from the local directory only.
</td></tr>
<tr><td><a href="#dist"><tt>dist</tt></a></td><td>all</td>
<td>Prepare a source distribution tarball.
</td></tr>
<tr><td><a href="#dist-check"><tt>dist-check</tt></a></td><td>all check</td>
<td>Prepare a source distribution tarball and check that it builds.
</td></tr>
<tr><td><a href="#dist-clean"><tt>dist-clean</tt></a></td><td>clean</td>
<td>Clean source distribution tarball temporary files.
</td></tr>
<tr><td><a href="#install"><tt>install</tt></a></td><td>all</td>
<td>Copy built objects to installation directory.
</td></tr>
<tr><td><a href="#tags"><tt>tags</tt></a></td><td></td>
<td>Make C and C++ tags files for emacs and vi.
</td></tr>
<tr><td><a href="#uninstall"><tt>uninstall</tt></a></td><td></td>
<td>Remove built objects from installation directory.
</td></tr>
</table>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="all">all (default)</a></div>
<div class="doc_text">
<p>When you invoke <tt>make</tt> with no arguments, you are implicitly
instructing it to seek the "all" target (goal). This target is used for
building the software recursively and will do different things in different
directories. For example, in a <tt>lib</tt> directory, the "all" target will
compile source files and generate libraries. But, in a <tt>tools</tt>
directory, it will link libraries and generate executables.</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="all-local">all-local</a></div>
<div class="doc_text">
<p>This target is the same as <a href="#all">all</a> but it operates only on
the current directory instead of recursively.</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="check">check</a></div>
<div class="doc_text">
<p>This target is used to perform any functional, unit or sanity tests as the
software is being built. The <tt>check</tt> target depends on the
<a href="#all"><tt>all</tt></a> target so the software is built in each
directory first and then the "check" is applied.</p>
<p>The definition of "check" is pretty general. It depends on the value of the
<a href="#TESTS"><tt>TESTS</tt></a> variable. This variable should be set to a
list of executables to run in order to test the software. If they all return
0 then the check succeeds, otherwise not. The programs run can be anything but
they should either be local to the directory or in your path.</p>
</div>
<div class="doc_warning"><p>Not implemented yet!</p></div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="check-local">check-local</a></div>
<div class="doc_text">
<p>This target does the same thing as <tt>check</tt> but only for the current
(local) directory.</p>
</div>
<div class="doc_warning"><p>Not implemented yet!</p></div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="clean">clean</a></div>
<div class="doc_text">
<p>This target cleans the build directory, recursively removing all things
that the Makefile builds. Despite once or twice attempting to remove /*, the
cleaning rules have been made guarded so they shouldn't go awry.</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="clean-local">clean-local</a></div>
<div class="doc_text">
<p>This target does the same thing as <tt>clean</tt> but only for the current
(local) directory.</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="dist">dist</a></div>
<div class="doc_text">
<p>This target builds a distribution tarball. It first builds the entire
project using the <tt>all</tt> target and then tars up the necessary files and
compresses it. The generated tarball is sufficient for a casual source
distribution, but probably not for a release (see <tt>dist-check</tt>).</p>
</div>
<div class="doc_warning"><p>Not implemented yet!</p></div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="dist-check">dist-check</a></div>
<div class="doc_text">
<p>This target does the same thing as the <tt>dist</tt> target but also checks
the distribution tarball. The check is made by unpacking the tarball to a new
directory, configuring it, building it, installing it, and then verifying that
the installation results are correct (by comparing to the original build).
This target can take a long time to run but should be done before a release
goes out to make sure that the distributed tarball can actually be built into
a working release.</p>
</div>
<div class="doc_warning"><p>Not implemented yet!</p></div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="dist-clean">dist-clean</a></div>
<div class="doc_text">
<p>This is a special form of the <tt>clean</tt> clean target. It performs a
normal <tt>clean</tt> but also removes things pertaining to building the
distribution.</p>
</div>
<div class="doc_warning"><p>Not implemented yet!</p></div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="install">install</a></div>
<div class="doc_text">
<p>This target finalizes shared objects and executables and copies all
libraries, headers and executables to the directory given with the
<tt>--prefix</tt> option to <tt>configure</tt>. When completed, the prefix
directory will have everything needed to <b>use</b> LLVM. </p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="printvars">printvars</a></div>
<div class="doc_text">
<p>This utility target just causes LLVM to print out some of its variables so
that you can double check how things are set. </p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="tags">tags</a></div>
<div class="doc_text">
<p>This target will generate a <tt>TAGS</tt> file in the top-level source
directory. It is meant for use with emacs, XEmacs, or ViM. The TAGS file
provides an index of symbol definitions so that the editor can jump you to the
definition quickly. </p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="uninstall">uninstall</a></div>
<div class="doc_text">
<p>This target is the opposite of the <tt>install</tt> target. It removes the
header, library and executable files from the installation directories. Note
that the directories themselves are not removed because it is not guaranteed
that LLVM is the only thing installing there (e.g. --prefix=/usr).</p>
</div>
<!-- *********************************************************************** -->
<div class="doc_section"><a name="variables">Variables</a></div>
<!-- *********************************************************************** -->
<div class="doc_text">
<p>Variables are used to tell the LLVM Makefile System what to do and to
obtain information from it. The sections below describe the three kinds of
variables.</p>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="setvars">Control Variables</a></div>
<div class="doc_text">
<p>Variables listed in the table below should be set <em>before</em> the
inclusion of <a href="Makefile.common"><tt>$(LEVEL)/Makefile.common</tt></a>.
These variables provide input to the LLVM make system that tell it what to do
for the current directory.</p>
<table style="text-align:left">
<tr><th>Variable Name</th><th>Variable Description</th></tr>
<tr>
<td><a href="#BUILD_ARCHIVE"><tt>BUILD_ARCHIVE</tt></a></td>
<td>If set to any value, causes an archive (.a) library to be built.</td>
</tr><tr><td><a href="#BUILT_SOURCES"><tt>BUILT_SOURCES</tt></a></td>
<td>Specifies a set of source files that are generated. These will be
built before any other target processing to ensure they are present.</td>
</tr><tr><td><a href="#BYTECODE_LIBRARY"><tt>BUILT_SOURCES</tt></a></td>
<td>If set to any value, causes a bytecode library (.bc) to be built.</td>
</tr><tr><td><a href="#CONFIG_FILES"><tt>BUILT_SOURCES</tt></a></td>
<td>Specifies a set of configuration files to be installed.</td>
</tr><tr><td><a href="#DIRS"><tt>DIRS</tt></a></td>
<td>Specifies a set of directories that should also be made using the
same goal. These directories will be built serially.</td>
</tr><tr><td><a href="#DONT_BUILD_RELINKED"><tt>DONT_BUILD_RELINKED</tt></a></td>
<td>If set to any value, causes a relinked library (.o) not to be built.</td>
</tr><tr><td><a href="#EXPORTED_SYMBOL_FILE"><tt>EXPORTED_SYMBOL_FILE</tt></a></td>
<td>Specifies the name of a single file that contains a list of the
symbols to be exported by the linker. One symbol per line.</td>
</tr><tr><td><a href="#LEVEL"><tt>LEVEL</tt></a></td>
<td>Specify the level of nesting from the top level. (Required)</td>
</tr><tr><td><a href="#LIBRARYNAME"><tt>LIBRARYNAME</tt></a></td>
<td>Specify the name of the library to be built. (Required For Libraries)</td>
</tr><tr><td><a href="#LLVMLIBS"><tt>LLVMLIBS</tt></a></td>
<td>Specify the set of libraries from the LLVM $(OBJDIR) that will be
linked into the tool or library.</td>
</tr><tr><td><a href="#EXPERIMENTAL_DIRS"><tt>EXPERIMENTAL_DIRS</tt></a></td>
<td>Specify a set of directories that should be built, but if they fail,
it should not cause the build to fail. Note that this should only be
used temporarily while code is being written.</td>
</tr><tr><td><a href="#OPTIONAL_DIRS"><tt>OPTIONAL_DIRS</tt></a></td>
<td>Specify a set of directories that may be built, if they exist, but its
not an error for them not to exist.</td>
</tr><tr><td><a href="#PARALLEL_DIRS"><tt>PARALLEL_DIRS</tt></a></td>
<td>Specify a set of directories to build recursively and in parallel if
the -j option was used with <tt>make</tt>.</td>
</tr><tr><td><a href="#SHARED_LIBRARY"><tt>SHARED_LIBRARY</tt></a></td>
<td>If set to any value, causes a shared library (.so) to be built.
(Optional)</td>
</tr><tr><td><a href="#SOURCES"><tt>SOURCES</tt></a></td>
<td>Specifies the list of source files in the current directory to be
acted upon. Source files of any type may be specified (programs,
documentation, config files, etc.)</td>
</tr><tr><td><a href="#TARGET"><tt>TARGET</tt></a></td>
<td>Specifies the name of the LLVM code generation target that the
current directory builds.</td>
</tr><tr><td><a href="#TOOLNAME"><tt>TOOLNAME</tt></a></td>
<td>Specifies the name of the tool to build. (Required For Tools)</td>
</tr><tr><td><a href="#USEDLIBS"><tt>USEDLIBS</tt></a></td>
<td>Specifies the list of project libraries that will be linked into the
tool or library.</td>
</tr>
</table>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="overvars">Overridable Variables</a></div>
<div class="doc_text">
<p>Variables listed in the table below can be used to override the default
values provided by the LLVM makefile system. These variables should be set
<em>after</em> the inclusion of <a
href="Makefile.common"><tt>$(LEVEL)/Makefile.common</tt></a>.</p>
<table style="text-align:left">
<tr><th>Variable Name</th><th>Variable Description</th></tr>
<tr>
<td><a href="#C"><tt>C</tt></a></td>
<td>The name (and optional path) of the 'C' compiler (gcc normally).</td>
</tr>
<tr>
<td><a href="#CFLAGS"><tt>CFLAGS</tt></a></td>
<td>The set of options to be passed to the 'C' compiler on <em>every</em>
compile.</td>
</tr>
<tr>
<td><a href="#CPP"><tt>CPP</tt></a></td>
<td>The name (and optional path) of the 'C' pre-processor (cpp normally).
</td>
</tr>
<tr>
<td><a href="#CXX"><tt>CXX</tt></a></td>
<td>The name (and optional path) of the C++ compiler (g++ normally).</td>
</tr>
<tr>
<td><a href="#LD"><tt>LD</tt></a></td>
<td>The name (and optional path) of the system linker (gcc normally).</td>
</tr>
<tr>
<td><a href="#LIBTOOL"><tt>LIBTOOL</tt></a></td>
<td>The name (and optional path) of the libtool tool (libtool normally).</td>
</tr>
</table>
</div>
<!-- ======================================================================= -->
<div class="doc_subsection"><a name="getvars">Readable Variables</a></div>
<div class="doc_text">
<p>Variables listed in the table below can be used by the user's Makefile but
should not be changed. Changing the value will generally cause the build to go
wrong, so don't do it.</p>
<table style="text-align:left">
<tr><th>Variable Name</th><th>Variable Description</th></tr>
<tr>
<td><a href="#BUILD_SRC_DIR"><tt>BUILD_SRC_DIR</tt></a></td>
<td>The project directory containing the directories source files.</td>
</tr>
<tr>
<td><a href="#BUILD_OBJ_DIR"><tt>BUILD_OBJ_DIR</tt></a></td>
<td>The project directory that will receive the object files.</td>
</tr>
<tr>
<td><a href="#CONFIGURATION"><tt>CONFIGURATION</tt></a></td>
<td>The name of the configuration being built.</td>
</tr>
<tr>
<td><a href="#DESTDIR"><tt>DESTDIR</tt></a></td>
<td>The top level directory into which files are installed.</td>
</tr>
<tr>
<td><a href="#LLVM_SRC_ROOT"><tt>LLVM_SRC_ROOT</tt></a></td>
<td>The top level directory of the LLVM source.</td>
</tr>
<tr>
<td><a href="#LLVM_OBJ_ROOT"><tt>LLVM_OBJ_ROOT</tt></a></td>
<td>The top level directory of the LLVM objects.</td>
</tr>
<tr>
<td><a href="#OBJDIR"><tt>OBJDIR</tt></a></td>
<td>The directory in which the project's object files should be placed.</td>
</tr>
<tr>
<td><a href="#LIBDIR"><tt>LIBDIR</tt></a></td>
<td>The directory in which the project's library files should be placed.</td>
</tr>
<tr>
<td><a href="#TOOLDIR"><tt>TOOLDIR</tt></a></td>
<td>The directory in which the project's executable tools should be
placed.</td>
</tr>
</table>
</div>
<!-- *********************************************************************** -->
<hr>
<address>
<a href="http://jigsaw.w3.org/css-validator/check/referer"><img
src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
<a href="http://validator.w3.org/check/referer"><img
src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a>
<a href="mailto:rspencer@x10sys.com">Reid Spencer</a><br>
<a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a><br>
Last modified: $Date$
</address>
</body>
</html>
<!-- vim: sw=2 noai
-->