blob: 910ebdb426db2c7846ec2901138620eb165259f8 [file] [log] [blame]
Misha Brukmanf6a04072004-05-12 20:57:43 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
John Criswellf2413ae2003-07-03 15:37:52 +00003<html>
Misha Brukmanf6a04072004-05-12 20:57:43 +00004<head>
5 <title>Creating an LLVM Project</title>
6 <link rel="stylesheet" href="llvm.css" type="text/css">
7</head>
8<body>
John Criswellf2413ae2003-07-03 15:37:52 +00009
NAKAMURA Takumi05d02652011-04-18 23:59:50 +000010<h1>Creating an LLVM Project</h1>
John Criswellf2413ae2003-07-03 15:37:52 +000011
Misha Brukmanf6a04072004-05-12 20:57:43 +000012<ol>
13<li><a href="#overview">Overview</a></li>
14<li><a href="#create">Create a project from the Sample Project</a></li>
15<li><a href="#source">Source tree layout</a></li>
16<li><a href="#makefiles">Writing LLVM-style Makefiles</a>
17 <ol>
18 <li><a href="#reqVars">Required Variables</a></li>
19 <li><a href="#varsBuildDir">Variables for Building Subdirectories</a></li>
20 <li><a href="#varsBuildLib">Variables for Building Libraries</a></li>
21 <li><a href="#varsBuildProg">Variables for Building Programs</a></li>
22 <li><a href="#miscVars">Miscellaneous Variables</a></li>
23 </ol></li>
24<li><a href="#objcode">Placement of object code</a></li>
25<li><a href="#help">Further help</a></li>
26</ol>
John Criswellf2413ae2003-07-03 15:37:52 +000027
Chris Lattner7911ce22004-05-23 21:07:27 +000028<div class="doc_author">
29 <p>Written by John Criswell</p>
30</div>
31
Misha Brukmanf6a04072004-05-12 20:57:43 +000032<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +000033<h2><a name="overview">Overview</a></h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +000034<!-- *********************************************************************** -->
John Criswellf2413ae2003-07-03 15:37:52 +000035
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +000036<div>
John Criswell7a4b96d2003-10-16 19:53:53 +000037
Misha Brukmanf6a04072004-05-12 20:57:43 +000038<p>The LLVM build system is designed to facilitate the building of third party
39projects that use LLVM header files, libraries, and tools. In order to use
40these facilities, a Makefile from a project must do the following things:</p>
John Criswell7a4b96d2003-10-16 19:53:53 +000041
Misha Brukmanf6a04072004-05-12 20:57:43 +000042<ol>
Reid Spencer39865c02005-01-16 02:21:18 +000043 <li>Set <tt>make</tt> variables. There are several variables that a Makefile
44 needs to set to use the LLVM build system:
45 <ul>
46 <li><tt>PROJECT_NAME</tt> - The name by which your project is known.</li>
47 <li><tt>LLVM_SRC_ROOT</tt> - The root of the LLVM source tree.</li>
48 <li><tt>LLVM_OBJ_ROOT</tt> - The root of the LLVM object tree.</li>
49 <li><tt>PROJ_SRC_ROOT</tt> - The root of the project's source tree.</li>
50 <li><tt>PROJ_OBJ_ROOT</tt> - The root of the project's object tree.</li>
51 <li><tt>PROJ_INSTALL_ROOT</tt> - The root installation directory.</li>
Andrew Trick0fb684d2011-06-03 02:16:53 +000052 <li><tt>LEVEL</tt> - The relative path from the current directory to the
Reid Spencer39865c02005-01-16 02:21:18 +000053 project's root ($PROJ_OBJ_ROOT).</li>
54 </ul></li>
55 <li>Include <tt>Makefile.config</tt> from <tt>$(LLVM_OBJ_ROOT)</tt>.</li>
56 <li>Include <tt>Makefile.rules</tt> from <tt>$(LLVM_SRC_ROOT)</tt>.</li>
Misha Brukmanf6a04072004-05-12 20:57:43 +000057</ol>
John Criswell7a4b96d2003-10-16 19:53:53 +000058
Misha Brukmanf6a04072004-05-12 20:57:43 +000059<p>There are two ways that you can set all of these variables:</p>
Misha Brukmanf6a04072004-05-12 20:57:43 +000060<ol>
Reid Spencer39865c02005-01-16 02:21:18 +000061 <li>You can write your own Makefiles which hard-code these values.</li>
Andrew Trick0fb684d2011-06-03 02:16:53 +000062 <li>You can use the pre-made LLVM sample project. This sample project
63 includes Makefiles, a configure script that can be used to configure the
64 location of LLVM, and the ability to support multiple object directories
Reid Spencer39865c02005-01-16 02:21:18 +000065 from a single source directory.</li>
Misha Brukmanf6a04072004-05-12 20:57:43 +000066</ol>
John Criswell7a4b96d2003-10-16 19:53:53 +000067
Reid Spencer39865c02005-01-16 02:21:18 +000068<p>This document assumes that you will base your project on the LLVM sample
Misha Brukmanf6a04072004-05-12 20:57:43 +000069project found in <tt>llvm/projects/sample</tt>. If you want to devise your own
70build system, studying the sample project and LLVM Makefiles will probably
71provide enough information on how to write your own Makefiles.</p>
John Criswell7a4b96d2003-10-16 19:53:53 +000072
Misha Brukmanf6a04072004-05-12 20:57:43 +000073</div>
John Criswell7a4b96d2003-10-16 19:53:53 +000074
Misha Brukmanf6a04072004-05-12 20:57:43 +000075<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +000076<h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +000077 <a name="create">Create a Project from the Sample Project</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +000078</h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +000079<!-- *********************************************************************** -->
John Criswell7a4b96d2003-10-16 19:53:53 +000080
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +000081<div>
John Criswell7a4b96d2003-10-16 19:53:53 +000082
Misha Brukmanf6a04072004-05-12 20:57:43 +000083<p>Follow these simple steps to start your project:</p>
John Criswell7a4b96d2003-10-16 19:53:53 +000084
Misha Brukmanf6a04072004-05-12 20:57:43 +000085<ol>
86<li>Copy the <tt>llvm/projects/sample</tt> directory to any place of your
87choosing. You can place it anywhere you like. Rename the directory to match
88the name of your project.</li>
John Criswell7a4b96d2003-10-16 19:53:53 +000089
John Criswellff3468e2005-10-24 16:43:08 +000090<li>
Andrew Trick0fb684d2011-06-03 02:16:53 +000091If you downloaded LLVM using Subversion, remove all the directories named .svn
92(and all the files therein) from your project's new source tree. This will
93keep Subversion from thinking that your project is inside
Reid Spencer669ed452007-07-09 08:04:31 +000094<tt>llvm/trunk/projects/sample</tt>.</li>
John Criswellff3468e2005-10-24 16:43:08 +000095
Misha Brukmanf6a04072004-05-12 20:57:43 +000096<li>Add your source code and Makefiles to your source tree.</li>
John Criswell7a4b96d2003-10-16 19:53:53 +000097
Reid Spencer5175b822005-02-28 00:40:29 +000098<li>If you want your project to be configured with the <tt>configure</tt> script
99then you need to edit <tt>autoconf/configure.ac</tt> as follows:
100 <ul>
101 <li><b>AC_INIT</b>. Place the name of your project, its version number and
102 a contact email address for your project as the arguments to this macro</li>
Chris Lattner623751f2006-03-16 16:14:59 +0000103 <li><b>AC_CONFIG_AUX_DIR</b>. If your project isn't in the
Reid Spencer5175b822005-02-28 00:40:29 +0000104 <tt>llvm/projects</tt> directory then you might need to adjust this so that
105 it specifies a relative path to the <tt>llvm/autoconf</tt> directory.</li>
106 <li><b>LLVM_CONFIG_PROJECT</b>. Just leave this alone.</li>
107 <li><b>AC_CONFIG_SRCDIR</b>. Specify a path to a file name that identifies
Reid Spencer64f99302006-03-17 08:04:25 +0000108 your project; or just leave it at <tt>Makefile.common.in</tt></li>
Reid Spencer5175b822005-02-28 00:40:29 +0000109 <li><b>AC_CONFIG_FILES</b>. Do not change.</li>
110 <li><b>AC_CONFIG_MAKEFILE</b>. Use one of these macros for each Makefile
111 that your project uses. This macro arranges for your makefiles to be copied
112 from the source directory, unmodified, to the build directory.</li>
113 </ul>
114</li>
John Criswellf2413ae2003-07-03 15:37:52 +0000115
Misha Brukmanf6a04072004-05-12 20:57:43 +0000116<li>After updating <tt>autoconf/configure.ac</tt>, regenerate the
117configure script with these commands:
John Criswellf2413ae2003-07-03 15:37:52 +0000118
Misha Brukmanf6a04072004-05-12 20:57:43 +0000119<div class="doc_code">
120<p><tt>% cd autoconf<br>
Dan Gohman30e5e552009-01-12 21:29:24 +0000121 % ./AutoRegen.sh</tt></p>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000122</div>
John Criswellf2413ae2003-07-03 15:37:52 +0000123
Misha Brukman0f6d5f82009-08-13 20:08:52 +0000124<p>You must be using Autoconf version 2.59 or later and your aclocal version
125should be 1.9 or later.</p></li>
John Criswell7a4b96d2003-10-16 19:53:53 +0000126
Misha Brukmanf6a04072004-05-12 20:57:43 +0000127<li>Run <tt>configure</tt> in the directory in which you want to place
128object code. Use the following options to tell your project where it
129can find LLVM:
John Criswell7a4b96d2003-10-16 19:53:53 +0000130
Misha Brukmanf6a04072004-05-12 20:57:43 +0000131 <dl>
Reid Spencer5175b822005-02-28 00:40:29 +0000132 <dt><tt>--with-llvmsrc=&lt;directory&gt;</tt></dt>
133 <dd>Tell your project where the LLVM source tree is located.</dd>
Misha Brukmanf00ddb02008-12-11 18:23:24 +0000134 <dt><br><tt>--with-llvmobj=&lt;directory&gt;</tt></dt>
Reid Spencer5175b822005-02-28 00:40:29 +0000135 <dd>Tell your project where the LLVM object tree is located.</dd>
Misha Brukmanf00ddb02008-12-11 18:23:24 +0000136 <dt><br><tt>--prefix=&lt;directory&gt;</tt></dt>
Reid Spencer5175b822005-02-28 00:40:29 +0000137 <dd>Tell your project where it should get installed.</dd>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000138 </dl>
139</ol>
John Criswell7a4b96d2003-10-16 19:53:53 +0000140
Reid Spencer5175b822005-02-28 00:40:29 +0000141<p>That's it! Now all you have to do is type <tt>gmake</tt> (or <tt>make</tt>
Andrew Trick0fb684d2011-06-03 02:16:53 +0000142if your on a GNU/Linux system) in the root of your object directory, and your
Reid Spencer5175b822005-02-28 00:40:29 +0000143project should build.</p>
John Criswellf2413ae2003-07-03 15:37:52 +0000144
Misha Brukmanf6a04072004-05-12 20:57:43 +0000145</div>
John Criswell7a4b96d2003-10-16 19:53:53 +0000146
Misha Brukmanf6a04072004-05-12 20:57:43 +0000147<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000148<h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000149 <a name="source">Source Tree Layout</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000150</h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000151<!-- *********************************************************************** -->
John Criswellf2413ae2003-07-03 15:37:52 +0000152
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000153<div>
John Criswell7a4b96d2003-10-16 19:53:53 +0000154
Misha Brukmanf6a04072004-05-12 20:57:43 +0000155<p>In order to use the LLVM build system, you will want to organize your
156source code so that it can benefit from the build system's features.
157Mainly, you want your source tree layout to look similar to the LLVM
158source tree layout. The best way to do this is to just copy the
159project tree from <tt>llvm/projects/sample</tt> and modify it to meet
160your needs, but you can certainly add to it if you want.</p>
John Criswellf2413ae2003-07-03 15:37:52 +0000161
Misha Brukmanf6a04072004-05-12 20:57:43 +0000162<p>Underneath your top level directory, you should have the following
163directories:</p>
John Criswellf2413ae2003-07-03 15:37:52 +0000164
Misha Brukmanf6a04072004-05-12 20:57:43 +0000165<dl>
166 <dt><b>lib</b>
167 <dd>
168 This subdirectory should contain all of your library source
169 code. For each library that you build, you will have one
170 directory in <b>lib</b> that will contain that library's source
171 code.
John Criswellf2413ae2003-07-03 15:37:52 +0000172
Misha Brukmanf6a04072004-05-12 20:57:43 +0000173 <p>
174 Libraries can be object files, archives, or dynamic libraries.
175 The <b>lib</b> directory is just a convenient place for libraries
176 as it places them all in a directory from which they can be linked
177 later.
John Criswellf2413ae2003-07-03 15:37:52 +0000178
Misha Brukmanf6a04072004-05-12 20:57:43 +0000179 <dt><b>include</b>
180 <dd>
181 This subdirectory should contain any header files that are
182 global to your project. By global, we mean that they are used
183 by more than one library or executable of your project.
184 <p>
185 By placing your header files in <b>include</b>, they will be
186 found automatically by the LLVM build system. For example, if
187 you have a file <b>include/jazz/note.h</b>, then your source
188 files can include it simply with <b>#include "jazz/note.h"</b>.
John Criswellf2413ae2003-07-03 15:37:52 +0000189
Misha Brukmanf6a04072004-05-12 20:57:43 +0000190 <dt><b>tools</b>
191 <dd>
192 This subdirectory should contain all of your source
193 code for executables. For each program that you build, you
194 will have one directory in <b>tools</b> that will contain that
195 program's source code.
196 <p>
John Criswellf2413ae2003-07-03 15:37:52 +0000197
Misha Brukmanf6a04072004-05-12 20:57:43 +0000198 <dt><b>test</b>
199 <dd>
200 This subdirectory should contain tests that verify that your code
201 works correctly. Automated tests are especially useful.
202 <p>
Tanya Lattnerd10bc6e2004-12-08 17:25:46 +0000203 Currently, the LLVM build system provides basic support for tests.
204 The LLVM system provides the following:
Misha Brukmanf6a04072004-05-12 20:57:43 +0000205 <ul>
206 <li>
Tanya Lattnerd10bc6e2004-12-08 17:25:46 +0000207 LLVM provides a tcl procedure that is used by Dejagnu to run
208 tests. It can be found in <tt>llvm/lib/llvm-dg.exp</tt>. This
209 test procedure uses RUN lines in the actual test case to determine
210 how to run the test. See the <a
211 href="TestingGuide.html">TestingGuide</a> for more details. You
Andrew Trick0fb684d2011-06-03 02:16:53 +0000212 can easily write Makefile support similar to the Makefiles in
Misha Brukmanf00ddb02008-12-11 18:23:24 +0000213 <tt>llvm/test</tt> to use Dejagnu to run your project's tests.<br></li>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000214 <li>
John Criswell9e2485c2004-12-10 15:51:16 +0000215 LLVM contains an optional package called <tt>llvm-test</tt>
216 which provides benchmarks and programs that are known to compile with the
217 LLVM GCC front ends. You can use these
Misha Brukmanf6a04072004-05-12 20:57:43 +0000218 programs to test your code, gather statistics information, and
John Criswell9e2485c2004-12-10 15:51:16 +0000219 compare it to the current LLVM performance statistics.
Misha Brukmanf00ddb02008-12-11 18:23:24 +0000220 <br>Currently, there is no way to hook your tests directly into the
John Criswell9e2485c2004-12-10 15:51:16 +0000221 <tt>llvm/test</tt> testing harness. You will simply
Misha Brukmanf6a04072004-05-12 20:57:43 +0000222 need to find a way to use the source provided within that directory
223 on your own.
224 </ul>
225</dl>
John Criswell2b89a6a2003-10-21 19:35:06 +0000226
Misha Brukmanf6a04072004-05-12 20:57:43 +0000227<p>Typically, you will want to build your <b>lib</b> directory first followed by
228your <b>tools</b> directory.</p>
John Criswellf2413ae2003-07-03 15:37:52 +0000229
Misha Brukmanf6a04072004-05-12 20:57:43 +0000230</div>
John Criswellf2413ae2003-07-03 15:37:52 +0000231
Misha Brukmanf6a04072004-05-12 20:57:43 +0000232<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000233<h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000234 <a name="makefiles">Writing LLVM Style Makefiles</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000235</h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000236<!-- *********************************************************************** -->
John Criswellf2413ae2003-07-03 15:37:52 +0000237
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000238<div>
John Criswellf2413ae2003-07-03 15:37:52 +0000239
Misha Brukmanf6a04072004-05-12 20:57:43 +0000240<p>The LLVM build system provides a convenient way to build libraries and
241executables. Most of your project Makefiles will only need to define a few
242variables. Below is a list of the variables one can set and what they can
243do:</p>
John Criswellf2413ae2003-07-03 15:37:52 +0000244
Misha Brukmanf6a04072004-05-12 20:57:43 +0000245<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000246<h3>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000247 <a name="reqVars">Required Variables</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000248</h3>
John Criswellf2413ae2003-07-03 15:37:52 +0000249
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000250<div>
John Criswellf2413ae2003-07-03 15:37:52 +0000251
Misha Brukmanf6a04072004-05-12 20:57:43 +0000252<dl>
253 <dt>LEVEL
254 <dd>
255 This variable is the relative path from this Makefile to the
256 top directory of your project's source code. For example, if
257 your source code is in <tt>/tmp/src</tt>, then the Makefile in
258 <tt>/tmp/src/jump/high</tt> would set <tt>LEVEL</tt> to <tt>"../.."</tt>.
259</dl>
John Criswellf2413ae2003-07-03 15:37:52 +0000260
Misha Brukmanf6a04072004-05-12 20:57:43 +0000261</div>
John Criswellf2413ae2003-07-03 15:37:52 +0000262
Misha Brukmanf6a04072004-05-12 20:57:43 +0000263<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000264<h3>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000265 <a name="varsBuildDir">Variables for Building Subdirectories</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000266</h3>
John Criswellf2413ae2003-07-03 15:37:52 +0000267
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000268<div>
John Criswell37c154a2003-10-17 21:50:38 +0000269
Misha Brukmanf6a04072004-05-12 20:57:43 +0000270<dl>
271 <dt>DIRS
272 <dd>
273 This is a space separated list of subdirectories that should be
274 built. They will be built, one at a time, in the order
275 specified.
276 <p>
John Criswellf2413ae2003-07-03 15:37:52 +0000277
Misha Brukmanf6a04072004-05-12 20:57:43 +0000278 <dt>PARALLEL_DIRS
279 <dd>
280 This is a list of directories that can be built in parallel.
281 These will be built after the directories in DIRS have been
282 built.
283 <p>
John Criswellf2413ae2003-07-03 15:37:52 +0000284
Misha Brukmanf6a04072004-05-12 20:57:43 +0000285 <dt>OPTIONAL_DIRS
286 <dd>
287 This is a list of directories that can be built if they exist,
288 but will not cause an error if they do not exist. They are
289 built serially in the order in which they are listed.
290</dl>
John Criswellf2413ae2003-07-03 15:37:52 +0000291
Misha Brukmanf6a04072004-05-12 20:57:43 +0000292</div>
John Criswell7a4b96d2003-10-16 19:53:53 +0000293
Misha Brukmanf6a04072004-05-12 20:57:43 +0000294<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000295<h3>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000296 <a name="varsBuildLib">Variables for Building Libraries</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000297</h3>
John Criswell7a4b96d2003-10-16 19:53:53 +0000298
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000299<div>
John Criswell7a4b96d2003-10-16 19:53:53 +0000300
Misha Brukmanf6a04072004-05-12 20:57:43 +0000301<dl>
302 <dt>LIBRARYNAME
303 <dd>
304 This variable contains the base name of the library that will
305 be built. For example, to build a library named
306 <tt>libsample.a</tt>, LIBRARYNAME should be set to
307 <tt>sample</tt>.
308 <p>
John Criswell7a4b96d2003-10-16 19:53:53 +0000309
Misha Brukmanf6a04072004-05-12 20:57:43 +0000310 <dt>BUILD_ARCHIVE
311 <dd>
312 By default, a library is a <tt>.o</tt> file that is linked
313 directly into a program. To build an archive (also known as
314 a static library), set the BUILD_ARCHIVE variable.
315 <p>
John Criswell7a4b96d2003-10-16 19:53:53 +0000316
Misha Brukmanf6a04072004-05-12 20:57:43 +0000317 <dt>SHARED_LIBRARY
318 <dd>
319 If SHARED_LIBRARY is defined in your Makefile, a shared
320 (or dynamic) library will be built.
321</dl>
322
323</div>
324
325<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000326<h3>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000327 <a name="varsBuildProg">Variables for Building Programs</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000328</h3>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000329
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000330<div>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000331
332<dl>
333 <dt>TOOLNAME
334 <dd>
335 This variable contains the name of the program that will
336 be built. For example, to build an executable named
337 <tt>sample</tt>, TOOLNAME should be set to <tt>sample</tt>.
338 <p>
339
340 <dt>USEDLIBS
341 <dd>
Andrew Trick21ac2512011-06-03 02:20:48 +0000342 This variable holds a space separated list of libraries that should
343 be linked into the program. These libraries must be libraries that
344 come from your <b>lib</b> directory. The libraries must be
345 specified without their "lib" prefix. For example, to link
346 libsample.a, you would set USEDLIBS to
347 <tt>sample.a</tt>.
Misha Brukmanf6a04072004-05-12 20:57:43 +0000348 <p>
349 Note that this works only for statically linked libraries.
350 <p>
351
Andrew Trick21ac2512011-06-03 02:20:48 +0000352 <dt>LLVMLIBS
353 <dd>
354 This variable holds a space separated list of libraries that should
355 be linked into the program. These libraries must be LLVM libraries.
356 The libraries must be specified without their "lib" prefix. For
357 example, to link with a driver that performs an IR transformation
358 you might set LLVMLIBS to this minimal set of libraries
359 <tt>LLVMSupport.a LLVMCore.a LLVMBitReader.a LLVMAsmParser.a LLVMAnalysis.a LLVMTransformUtils.a LLVMScalarOpts.a LLVMTarget.a</tt>.
360 <p>
361 Note that this works only for statically linked libraries. LLVM is
362 split into a large number of static libraries, and the list of libraries you
363 require may be much longer than the list above. To see a full list
364 of libraries use:
365 <tt>llvm-config --libs all</tt>.
366 Using LINK_COMPONENTS as described below, obviates the need to set LLVMLIBS.
367 <p>
368
369 <dt>LINK_COMPONENTS
370 <dd>This variable holds a space separated list of components that
371 the LLVM Makefiles pass to the <tt>llvm-config</tt> tool to generate
372 a link line for the program. For example, to link with all LLVM
373 libraries use
374 <tt>LINK_COMPONENTS = all</tt>.
375 <p>
376
Misha Brukmanf6a04072004-05-12 20:57:43 +0000377 <dt>LIBS
378 <dd>
379 To link dynamic libraries, add <tt>-l&lt;library base name&gt;</tt> to
380 the LIBS variable. The LLVM build system will look in the same places
381 for dynamic libraries as it does for static libraries.
382 <p>
383 For example, to link <tt>libsample.so</tt>, you would have the
384 following line in your <tt>Makefile</tt>:
385 <p>
386 <tt>
387 LIBS += -lsample
388 </tt>
Andrew Trick21ac2512011-06-03 02:20:48 +0000389 <p>
390 Note that LIBS must occur in the Makefile after the inclusion of Makefile.common.
391 <p>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000392</dl>
393
394</div>
395
396<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000397<h3>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000398 <a name="miscVars">Miscellaneous Variables</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000399</h3>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000400
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000401<div>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000402
403<dl>
404 <dt>ExtraSource
405 <dd>
406 This variable contains a space separated list of extra source
407 files that need to be built. It is useful for including the
408 output of Lex and Yacc programs.
409 <p>
410
411 <dt>CFLAGS
412 <dt>CPPFLAGS
413 <dd>
414 This variable can be used to add options to the C and C++
415 compiler, respectively. It is typically used to add options
416 that tell the compiler the location of additional directories
417 to search for header files.
418 <p>
419 It is highly suggested that you append to CFLAGS and CPPFLAGS as
420 opposed to overwriting them. The master Makefiles may already
421 have useful options in them that you may not want to overwrite.
422 <p>
423</dl>
424
425</div>
426
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000427</div>
428
Misha Brukmanf6a04072004-05-12 20:57:43 +0000429<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000430<h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000431 <a name="objcode">Placement of Object Code</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000432</h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000433<!-- *********************************************************************** -->
434
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000435<div>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000436
437<p>The final location of built libraries and executables will depend upon
438whether you do a Debug, Release, or Profile build.</p>
439
440<dl>
441 <dt>Libraries
442 <dd>
443 All libraries (static and dynamic) will be stored in
Reid Spencerd967c802005-01-16 02:38:06 +0000444 <tt>PROJ_OBJ_ROOT/&lt;type&gt;/lib</tt>, where type is <tt>Debug</tt>,
Misha Brukmanf6a04072004-05-12 20:57:43 +0000445 <tt>Release</tt>, or <tt>Profile</tt> for a debug, optimized, or
446 profiled build, respectively.<p>
447
448 <dt>Executables
449 <dd>All executables will be stored in
Reid Spencerd967c802005-01-16 02:38:06 +0000450 <tt>PROJ_OBJ_ROOT/&lt;type&gt;/bin</tt>, where type is <tt>Debug</tt>,
Misha Brukmanf6a04072004-05-12 20:57:43 +0000451 <tt>Release</tt>, or <tt>Profile</tt> for a debug, optimized, or profiled
452 build, respectively.
453</dl>
454
455</div>
456
457<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000458<h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000459 <a name="help">Further Help</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000460</h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000461<!-- *********************************************************************** -->
462
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000463<div>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000464
465<p>If you have any questions or need any help creating an LLVM project,
466the LLVM team would be more than happy to help. You can always post your
467questions to the <a
468href="http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev">LLVM Developers
469Mailing List</a>.</p>
470
471</div>
Andrew Trick0fb684d2011-06-03 02:16:53 +0000472
Misha Brukmanf6a04072004-05-12 20:57:43 +0000473<!-- *********************************************************************** -->
John Criswell7a4b96d2003-10-16 19:53:53 +0000474<hr>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000475<address>
476 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
Misha Brukman44408702008-12-11 17:34:48 +0000477 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000478 <a href="http://validator.w3.org/check/referer"><img
Misha Brukmanf00ddb02008-12-11 18:23:24 +0000479 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000480
481 <a href="mailto:criswell@uiuc.edu">John Criswell</a><br>
NAKAMURA Takumib9a33632011-04-09 02:13:37 +0000482 <a href="http://llvm.org/">The LLVM Compiler Infrastructure</a>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000483 <br>
484 Last modified: $Date$
485</address>
Misha Brukman733adcb2003-10-30 01:23:40 +0000486
John Criswellf2413ae2003-07-03 15:37:52 +0000487</body>
488</html>