blob: 45f6af5711cc47d9c7eb75491a2e163c430bc236 [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>
NAKAMURA Takumi5c6e4df2011-10-31 11:21:59 +00005 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Misha Brukmanf6a04072004-05-12 20:57:43 +00006 <title>Creating an LLVM Project</title>
Daniel Dunbaradea4972012-04-19 20:20:34 +00007 <link rel="stylesheet" href="_static/llvm.css" type="text/css">
Misha Brukmanf6a04072004-05-12 20:57:43 +00008</head>
9<body>
John Criswellf2413ae2003-07-03 15:37:52 +000010
NAKAMURA Takumi05d02652011-04-18 23:59:50 +000011<h1>Creating an LLVM Project</h1>
John Criswellf2413ae2003-07-03 15:37:52 +000012
Misha Brukmanf6a04072004-05-12 20:57:43 +000013<ol>
14<li><a href="#overview">Overview</a></li>
15<li><a href="#create">Create a project from the Sample Project</a></li>
16<li><a href="#source">Source tree layout</a></li>
17<li><a href="#makefiles">Writing LLVM-style Makefiles</a>
18 <ol>
19 <li><a href="#reqVars">Required Variables</a></li>
20 <li><a href="#varsBuildDir">Variables for Building Subdirectories</a></li>
21 <li><a href="#varsBuildLib">Variables for Building Libraries</a></li>
22 <li><a href="#varsBuildProg">Variables for Building Programs</a></li>
23 <li><a href="#miscVars">Miscellaneous Variables</a></li>
24 </ol></li>
25<li><a href="#objcode">Placement of object code</a></li>
26<li><a href="#help">Further help</a></li>
27</ol>
John Criswellf2413ae2003-07-03 15:37:52 +000028
Chris Lattner7911ce22004-05-23 21:07:27 +000029<div class="doc_author">
30 <p>Written by John Criswell</p>
31</div>
32
Misha Brukmanf6a04072004-05-12 20:57:43 +000033<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +000034<h2><a name="overview">Overview</a></h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +000035<!-- *********************************************************************** -->
John Criswellf2413ae2003-07-03 15:37:52 +000036
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +000037<div>
John Criswell7a4b96d2003-10-16 19:53:53 +000038
Misha Brukmanf6a04072004-05-12 20:57:43 +000039<p>The LLVM build system is designed to facilitate the building of third party
40projects that use LLVM header files, libraries, and tools. In order to use
41these facilities, a Makefile from a project must do the following things:</p>
John Criswell7a4b96d2003-10-16 19:53:53 +000042
Misha Brukmanf6a04072004-05-12 20:57:43 +000043<ol>
Reid Spencer39865c02005-01-16 02:21:18 +000044 <li>Set <tt>make</tt> variables. There are several variables that a Makefile
45 needs to set to use the LLVM build system:
46 <ul>
47 <li><tt>PROJECT_NAME</tt> - The name by which your project is known.</li>
48 <li><tt>LLVM_SRC_ROOT</tt> - The root of the LLVM source tree.</li>
49 <li><tt>LLVM_OBJ_ROOT</tt> - The root of the LLVM object tree.</li>
50 <li><tt>PROJ_SRC_ROOT</tt> - The root of the project's source tree.</li>
51 <li><tt>PROJ_OBJ_ROOT</tt> - The root of the project's object tree.</li>
52 <li><tt>PROJ_INSTALL_ROOT</tt> - The root installation directory.</li>
Andrew Trick0fb684d2011-06-03 02:16:53 +000053 <li><tt>LEVEL</tt> - The relative path from the current directory to the
Reid Spencer39865c02005-01-16 02:21:18 +000054 project's root ($PROJ_OBJ_ROOT).</li>
55 </ul></li>
56 <li>Include <tt>Makefile.config</tt> from <tt>$(LLVM_OBJ_ROOT)</tt>.</li>
57 <li>Include <tt>Makefile.rules</tt> from <tt>$(LLVM_SRC_ROOT)</tt>.</li>
Misha Brukmanf6a04072004-05-12 20:57:43 +000058</ol>
John Criswell7a4b96d2003-10-16 19:53:53 +000059
Misha Brukmanf6a04072004-05-12 20:57:43 +000060<p>There are two ways that you can set all of these variables:</p>
Misha Brukmanf6a04072004-05-12 20:57:43 +000061<ol>
Reid Spencer39865c02005-01-16 02:21:18 +000062 <li>You can write your own Makefiles which hard-code these values.</li>
Andrew Trick0fb684d2011-06-03 02:16:53 +000063 <li>You can use the pre-made LLVM sample project. This sample project
64 includes Makefiles, a configure script that can be used to configure the
65 location of LLVM, and the ability to support multiple object directories
Reid Spencer39865c02005-01-16 02:21:18 +000066 from a single source directory.</li>
Misha Brukmanf6a04072004-05-12 20:57:43 +000067</ol>
John Criswell7a4b96d2003-10-16 19:53:53 +000068
Reid Spencer39865c02005-01-16 02:21:18 +000069<p>This document assumes that you will base your project on the LLVM sample
Misha Brukmanf6a04072004-05-12 20:57:43 +000070project found in <tt>llvm/projects/sample</tt>. If you want to devise your own
71build system, studying the sample project and LLVM Makefiles will probably
72provide enough information on how to write your own Makefiles.</p>
John Criswell7a4b96d2003-10-16 19:53:53 +000073
Misha Brukmanf6a04072004-05-12 20:57:43 +000074</div>
John Criswell7a4b96d2003-10-16 19:53:53 +000075
Misha Brukmanf6a04072004-05-12 20:57:43 +000076<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +000077<h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +000078 <a name="create">Create a Project from the Sample Project</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +000079</h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +000080<!-- *********************************************************************** -->
John Criswell7a4b96d2003-10-16 19:53:53 +000081
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +000082<div>
John Criswell7a4b96d2003-10-16 19:53:53 +000083
Misha Brukmanf6a04072004-05-12 20:57:43 +000084<p>Follow these simple steps to start your project:</p>
John Criswell7a4b96d2003-10-16 19:53:53 +000085
Misha Brukmanf6a04072004-05-12 20:57:43 +000086<ol>
87<li>Copy the <tt>llvm/projects/sample</tt> directory to any place of your
88choosing. You can place it anywhere you like. Rename the directory to match
89the name of your project.</li>
John Criswell7a4b96d2003-10-16 19:53:53 +000090
John Criswellff3468e2005-10-24 16:43:08 +000091<li>
Andrew Trick0fb684d2011-06-03 02:16:53 +000092If you downloaded LLVM using Subversion, remove all the directories named .svn
93(and all the files therein) from your project's new source tree. This will
94keep Subversion from thinking that your project is inside
Reid Spencer669ed452007-07-09 08:04:31 +000095<tt>llvm/trunk/projects/sample</tt>.</li>
John Criswellff3468e2005-10-24 16:43:08 +000096
Misha Brukmanf6a04072004-05-12 20:57:43 +000097<li>Add your source code and Makefiles to your source tree.</li>
John Criswell7a4b96d2003-10-16 19:53:53 +000098
Reid Spencer5175b822005-02-28 00:40:29 +000099<li>If you want your project to be configured with the <tt>configure</tt> script
100then you need to edit <tt>autoconf/configure.ac</tt> as follows:
101 <ul>
102 <li><b>AC_INIT</b>. Place the name of your project, its version number and
103 a contact email address for your project as the arguments to this macro</li>
Chris Lattner623751f2006-03-16 16:14:59 +0000104 <li><b>AC_CONFIG_AUX_DIR</b>. If your project isn't in the
Reid Spencer5175b822005-02-28 00:40:29 +0000105 <tt>llvm/projects</tt> directory then you might need to adjust this so that
106 it specifies a relative path to the <tt>llvm/autoconf</tt> directory.</li>
107 <li><b>LLVM_CONFIG_PROJECT</b>. Just leave this alone.</li>
108 <li><b>AC_CONFIG_SRCDIR</b>. Specify a path to a file name that identifies
Reid Spencer64f99302006-03-17 08:04:25 +0000109 your project; or just leave it at <tt>Makefile.common.in</tt></li>
Reid Spencer5175b822005-02-28 00:40:29 +0000110 <li><b>AC_CONFIG_FILES</b>. Do not change.</li>
111 <li><b>AC_CONFIG_MAKEFILE</b>. Use one of these macros for each Makefile
112 that your project uses. This macro arranges for your makefiles to be copied
113 from the source directory, unmodified, to the build directory.</li>
114 </ul>
115</li>
John Criswellf2413ae2003-07-03 15:37:52 +0000116
Misha Brukmanf6a04072004-05-12 20:57:43 +0000117<li>After updating <tt>autoconf/configure.ac</tt>, regenerate the
118configure script with these commands:
John Criswellf2413ae2003-07-03 15:37:52 +0000119
Misha Brukmanf6a04072004-05-12 20:57:43 +0000120<div class="doc_code">
121<p><tt>% cd autoconf<br>
Dan Gohman30e5e552009-01-12 21:29:24 +0000122 % ./AutoRegen.sh</tt></p>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000123</div>
John Criswellf2413ae2003-07-03 15:37:52 +0000124
Misha Brukman0f6d5f82009-08-13 20:08:52 +0000125<p>You must be using Autoconf version 2.59 or later and your aclocal version
126should be 1.9 or later.</p></li>
John Criswell7a4b96d2003-10-16 19:53:53 +0000127
Misha Brukmanf6a04072004-05-12 20:57:43 +0000128<li>Run <tt>configure</tt> in the directory in which you want to place
129object code. Use the following options to tell your project where it
130can find LLVM:
John Criswell7a4b96d2003-10-16 19:53:53 +0000131
Misha Brukmanf6a04072004-05-12 20:57:43 +0000132 <dl>
Reid Spencer5175b822005-02-28 00:40:29 +0000133 <dt><tt>--with-llvmsrc=&lt;directory&gt;</tt></dt>
134 <dd>Tell your project where the LLVM source tree is located.</dd>
Misha Brukmanf00ddb02008-12-11 18:23:24 +0000135 <dt><br><tt>--with-llvmobj=&lt;directory&gt;</tt></dt>
Reid Spencer5175b822005-02-28 00:40:29 +0000136 <dd>Tell your project where the LLVM object tree is located.</dd>
Misha Brukmanf00ddb02008-12-11 18:23:24 +0000137 <dt><br><tt>--prefix=&lt;directory&gt;</tt></dt>
Reid Spencer5175b822005-02-28 00:40:29 +0000138 <dd>Tell your project where it should get installed.</dd>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000139 </dl>
140</ol>
John Criswell7a4b96d2003-10-16 19:53:53 +0000141
Reid Spencer5175b822005-02-28 00:40:29 +0000142<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 +0000143if your on a GNU/Linux system) in the root of your object directory, and your
Reid Spencer5175b822005-02-28 00:40:29 +0000144project should build.</p>
John Criswellf2413ae2003-07-03 15:37:52 +0000145
Misha Brukmanf6a04072004-05-12 20:57:43 +0000146</div>
John Criswell7a4b96d2003-10-16 19:53:53 +0000147
Misha Brukmanf6a04072004-05-12 20:57:43 +0000148<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000149<h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000150 <a name="source">Source Tree Layout</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000151</h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000152<!-- *********************************************************************** -->
John Criswellf2413ae2003-07-03 15:37:52 +0000153
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000154<div>
John Criswell7a4b96d2003-10-16 19:53:53 +0000155
Misha Brukmanf6a04072004-05-12 20:57:43 +0000156<p>In order to use the LLVM build system, you will want to organize your
157source code so that it can benefit from the build system's features.
158Mainly, you want your source tree layout to look similar to the LLVM
159source tree layout. The best way to do this is to just copy the
160project tree from <tt>llvm/projects/sample</tt> and modify it to meet
161your needs, but you can certainly add to it if you want.</p>
John Criswellf2413ae2003-07-03 15:37:52 +0000162
Misha Brukmanf6a04072004-05-12 20:57:43 +0000163<p>Underneath your top level directory, you should have the following
164directories:</p>
John Criswellf2413ae2003-07-03 15:37:52 +0000165
Misha Brukmanf6a04072004-05-12 20:57:43 +0000166<dl>
167 <dt><b>lib</b>
168 <dd>
169 This subdirectory should contain all of your library source
170 code. For each library that you build, you will have one
171 directory in <b>lib</b> that will contain that library's source
172 code.
John Criswellf2413ae2003-07-03 15:37:52 +0000173
Misha Brukmanf6a04072004-05-12 20:57:43 +0000174 <p>
175 Libraries can be object files, archives, or dynamic libraries.
176 The <b>lib</b> directory is just a convenient place for libraries
177 as it places them all in a directory from which they can be linked
178 later.
John Criswellf2413ae2003-07-03 15:37:52 +0000179
Misha Brukmanf6a04072004-05-12 20:57:43 +0000180 <dt><b>include</b>
181 <dd>
182 This subdirectory should contain any header files that are
183 global to your project. By global, we mean that they are used
184 by more than one library or executable of your project.
185 <p>
186 By placing your header files in <b>include</b>, they will be
187 found automatically by the LLVM build system. For example, if
188 you have a file <b>include/jazz/note.h</b>, then your source
189 files can include it simply with <b>#include "jazz/note.h"</b>.
John Criswellf2413ae2003-07-03 15:37:52 +0000190
Misha Brukmanf6a04072004-05-12 20:57:43 +0000191 <dt><b>tools</b>
192 <dd>
193 This subdirectory should contain all of your source
194 code for executables. For each program that you build, you
195 will have one directory in <b>tools</b> that will contain that
196 program's source code.
197 <p>
John Criswellf2413ae2003-07-03 15:37:52 +0000198
Misha Brukmanf6a04072004-05-12 20:57:43 +0000199 <dt><b>test</b>
200 <dd>
201 This subdirectory should contain tests that verify that your code
202 works correctly. Automated tests are especially useful.
203 <p>
Tanya Lattnerd10bc6e2004-12-08 17:25:46 +0000204 Currently, the LLVM build system provides basic support for tests.
205 The LLVM system provides the following:
Misha Brukmanf6a04072004-05-12 20:57:43 +0000206 <ul>
207 <li>
Tanya Lattnerd10bc6e2004-12-08 17:25:46 +0000208 LLVM provides a tcl procedure that is used by Dejagnu to run
209 tests. It can be found in <tt>llvm/lib/llvm-dg.exp</tt>. This
210 test procedure uses RUN lines in the actual test case to determine
211 how to run the test. See the <a
212 href="TestingGuide.html">TestingGuide</a> for more details. You
Andrew Trick0fb684d2011-06-03 02:16:53 +0000213 can easily write Makefile support similar to the Makefiles in
Misha Brukmanf00ddb02008-12-11 18:23:24 +0000214 <tt>llvm/test</tt> to use Dejagnu to run your project's tests.<br></li>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000215 <li>
John Criswell9e2485c2004-12-10 15:51:16 +0000216 LLVM contains an optional package called <tt>llvm-test</tt>
217 which provides benchmarks and programs that are known to compile with the
218 LLVM GCC front ends. You can use these
Misha Brukmanf6a04072004-05-12 20:57:43 +0000219 programs to test your code, gather statistics information, and
John Criswell9e2485c2004-12-10 15:51:16 +0000220 compare it to the current LLVM performance statistics.
Misha Brukmanf00ddb02008-12-11 18:23:24 +0000221 <br>Currently, there is no way to hook your tests directly into the
John Criswell9e2485c2004-12-10 15:51:16 +0000222 <tt>llvm/test</tt> testing harness. You will simply
Misha Brukmanf6a04072004-05-12 20:57:43 +0000223 need to find a way to use the source provided within that directory
224 on your own.
225 </ul>
226</dl>
John Criswell2b89a6a2003-10-21 19:35:06 +0000227
Misha Brukmanf6a04072004-05-12 20:57:43 +0000228<p>Typically, you will want to build your <b>lib</b> directory first followed by
229your <b>tools</b> directory.</p>
John Criswellf2413ae2003-07-03 15:37:52 +0000230
Misha Brukmanf6a04072004-05-12 20:57:43 +0000231</div>
John Criswellf2413ae2003-07-03 15:37:52 +0000232
Misha Brukmanf6a04072004-05-12 20:57:43 +0000233<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000234<h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000235 <a name="makefiles">Writing LLVM Style Makefiles</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000236</h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000237<!-- *********************************************************************** -->
John Criswellf2413ae2003-07-03 15:37:52 +0000238
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000239<div>
John Criswellf2413ae2003-07-03 15:37:52 +0000240
Misha Brukmanf6a04072004-05-12 20:57:43 +0000241<p>The LLVM build system provides a convenient way to build libraries and
242executables. Most of your project Makefiles will only need to define a few
243variables. Below is a list of the variables one can set and what they can
244do:</p>
John Criswellf2413ae2003-07-03 15:37:52 +0000245
Misha Brukmanf6a04072004-05-12 20:57:43 +0000246<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000247<h3>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000248 <a name="reqVars">Required Variables</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000249</h3>
John Criswellf2413ae2003-07-03 15:37:52 +0000250
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000251<div>
John Criswellf2413ae2003-07-03 15:37:52 +0000252
Misha Brukmanf6a04072004-05-12 20:57:43 +0000253<dl>
254 <dt>LEVEL
255 <dd>
256 This variable is the relative path from this Makefile to the
257 top directory of your project's source code. For example, if
258 your source code is in <tt>/tmp/src</tt>, then the Makefile in
259 <tt>/tmp/src/jump/high</tt> would set <tt>LEVEL</tt> to <tt>"../.."</tt>.
260</dl>
John Criswellf2413ae2003-07-03 15:37:52 +0000261
Misha Brukmanf6a04072004-05-12 20:57:43 +0000262</div>
John Criswellf2413ae2003-07-03 15:37:52 +0000263
Misha Brukmanf6a04072004-05-12 20:57:43 +0000264<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000265<h3>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000266 <a name="varsBuildDir">Variables for Building Subdirectories</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000267</h3>
John Criswellf2413ae2003-07-03 15:37:52 +0000268
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000269<div>
John Criswell37c154a2003-10-17 21:50:38 +0000270
Misha Brukmanf6a04072004-05-12 20:57:43 +0000271<dl>
272 <dt>DIRS
273 <dd>
274 This is a space separated list of subdirectories that should be
275 built. They will be built, one at a time, in the order
276 specified.
277 <p>
John Criswellf2413ae2003-07-03 15:37:52 +0000278
Misha Brukmanf6a04072004-05-12 20:57:43 +0000279 <dt>PARALLEL_DIRS
280 <dd>
281 This is a list of directories that can be built in parallel.
282 These will be built after the directories in DIRS have been
283 built.
284 <p>
John Criswellf2413ae2003-07-03 15:37:52 +0000285
Misha Brukmanf6a04072004-05-12 20:57:43 +0000286 <dt>OPTIONAL_DIRS
287 <dd>
288 This is a list of directories that can be built if they exist,
289 but will not cause an error if they do not exist. They are
290 built serially in the order in which they are listed.
291</dl>
John Criswellf2413ae2003-07-03 15:37:52 +0000292
Misha Brukmanf6a04072004-05-12 20:57:43 +0000293</div>
John Criswell7a4b96d2003-10-16 19:53:53 +0000294
Misha Brukmanf6a04072004-05-12 20:57:43 +0000295<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000296<h3>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000297 <a name="varsBuildLib">Variables for Building Libraries</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000298</h3>
John Criswell7a4b96d2003-10-16 19:53:53 +0000299
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000300<div>
John Criswell7a4b96d2003-10-16 19:53:53 +0000301
Misha Brukmanf6a04072004-05-12 20:57:43 +0000302<dl>
303 <dt>LIBRARYNAME
304 <dd>
305 This variable contains the base name of the library that will
306 be built. For example, to build a library named
307 <tt>libsample.a</tt>, LIBRARYNAME should be set to
308 <tt>sample</tt>.
309 <p>
John Criswell7a4b96d2003-10-16 19:53:53 +0000310
Misha Brukmanf6a04072004-05-12 20:57:43 +0000311 <dt>BUILD_ARCHIVE
312 <dd>
313 By default, a library is a <tt>.o</tt> file that is linked
314 directly into a program. To build an archive (also known as
315 a static library), set the BUILD_ARCHIVE variable.
316 <p>
John Criswell7a4b96d2003-10-16 19:53:53 +0000317
Misha Brukmanf6a04072004-05-12 20:57:43 +0000318 <dt>SHARED_LIBRARY
319 <dd>
320 If SHARED_LIBRARY is defined in your Makefile, a shared
321 (or dynamic) library will be built.
322</dl>
323
324</div>
325
326<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000327<h3>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000328 <a name="varsBuildProg">Variables for Building Programs</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000329</h3>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000330
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000331<div>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000332
333<dl>
334 <dt>TOOLNAME
335 <dd>
336 This variable contains the name of the program that will
337 be built. For example, to build an executable named
338 <tt>sample</tt>, TOOLNAME should be set to <tt>sample</tt>.
339 <p>
340
341 <dt>USEDLIBS
342 <dd>
Andrew Trick21ac2512011-06-03 02:20:48 +0000343 This variable holds a space separated list of libraries that should
344 be linked into the program. These libraries must be libraries that
345 come from your <b>lib</b> directory. The libraries must be
346 specified without their "lib" prefix. For example, to link
347 libsample.a, you would set USEDLIBS to
348 <tt>sample.a</tt>.
Misha Brukmanf6a04072004-05-12 20:57:43 +0000349 <p>
350 Note that this works only for statically linked libraries.
351 <p>
352
Andrew Trick21ac2512011-06-03 02:20:48 +0000353 <dt>LLVMLIBS
354 <dd>
355 This variable holds a space separated list of libraries that should
356 be linked into the program. These libraries must be LLVM libraries.
357 The libraries must be specified without their "lib" prefix. For
358 example, to link with a driver that performs an IR transformation
359 you might set LLVMLIBS to this minimal set of libraries
360 <tt>LLVMSupport.a LLVMCore.a LLVMBitReader.a LLVMAsmParser.a LLVMAnalysis.a LLVMTransformUtils.a LLVMScalarOpts.a LLVMTarget.a</tt>.
361 <p>
362 Note that this works only for statically linked libraries. LLVM is
363 split into a large number of static libraries, and the list of libraries you
364 require may be much longer than the list above. To see a full list
365 of libraries use:
366 <tt>llvm-config --libs all</tt>.
367 Using LINK_COMPONENTS as described below, obviates the need to set LLVMLIBS.
368 <p>
369
370 <dt>LINK_COMPONENTS
371 <dd>This variable holds a space separated list of components that
372 the LLVM Makefiles pass to the <tt>llvm-config</tt> tool to generate
373 a link line for the program. For example, to link with all LLVM
374 libraries use
375 <tt>LINK_COMPONENTS = all</tt>.
376 <p>
377
Misha Brukmanf6a04072004-05-12 20:57:43 +0000378 <dt>LIBS
379 <dd>
380 To link dynamic libraries, add <tt>-l&lt;library base name&gt;</tt> to
381 the LIBS variable. The LLVM build system will look in the same places
382 for dynamic libraries as it does for static libraries.
383 <p>
384 For example, to link <tt>libsample.so</tt>, you would have the
385 following line in your <tt>Makefile</tt>:
386 <p>
387 <tt>
388 LIBS += -lsample
389 </tt>
Andrew Trick21ac2512011-06-03 02:20:48 +0000390 <p>
391 Note that LIBS must occur in the Makefile after the inclusion of Makefile.common.
392 <p>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000393</dl>
394
395</div>
396
397<!-- ======================================================================= -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000398<h3>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000399 <a name="miscVars">Miscellaneous Variables</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000400</h3>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000401
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000402<div>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000403
404<dl>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000405 <dt>CFLAGS
406 <dt>CPPFLAGS
407 <dd>
408 This variable can be used to add options to the C and C++
409 compiler, respectively. It is typically used to add options
410 that tell the compiler the location of additional directories
411 to search for header files.
412 <p>
413 It is highly suggested that you append to CFLAGS and CPPFLAGS as
414 opposed to overwriting them. The master Makefiles may already
415 have useful options in them that you may not want to overwrite.
416 <p>
417</dl>
418
419</div>
420
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000421</div>
422
Misha Brukmanf6a04072004-05-12 20:57:43 +0000423<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000424<h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000425 <a name="objcode">Placement of Object Code</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000426</h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000427<!-- *********************************************************************** -->
428
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000429<div>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000430
431<p>The final location of built libraries and executables will depend upon
432whether you do a Debug, Release, or Profile build.</p>
433
434<dl>
435 <dt>Libraries
436 <dd>
437 All libraries (static and dynamic) will be stored in
Reid Spencerd967c802005-01-16 02:38:06 +0000438 <tt>PROJ_OBJ_ROOT/&lt;type&gt;/lib</tt>, where type is <tt>Debug</tt>,
Misha Brukmanf6a04072004-05-12 20:57:43 +0000439 <tt>Release</tt>, or <tt>Profile</tt> for a debug, optimized, or
440 profiled build, respectively.<p>
441
442 <dt>Executables
443 <dd>All executables will be stored in
Reid Spencerd967c802005-01-16 02:38:06 +0000444 <tt>PROJ_OBJ_ROOT/&lt;type&gt;/bin</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 profiled
446 build, respectively.
447</dl>
448
449</div>
450
451<!-- *********************************************************************** -->
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000452<h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000453 <a name="help">Further Help</a>
NAKAMURA Takumi05d02652011-04-18 23:59:50 +0000454</h2>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000455<!-- *********************************************************************** -->
456
NAKAMURA Takumif5af6ad2011-04-23 00:30:22 +0000457<div>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000458
459<p>If you have any questions or need any help creating an LLVM project,
460the LLVM team would be more than happy to help. You can always post your
461questions to the <a
462href="http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev">LLVM Developers
463Mailing List</a>.</p>
464
465</div>
Andrew Trick0fb684d2011-06-03 02:16:53 +0000466
Misha Brukmanf6a04072004-05-12 20:57:43 +0000467<!-- *********************************************************************** -->
John Criswell7a4b96d2003-10-16 19:53:53 +0000468<hr>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000469<address>
470 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
Misha Brukman44408702008-12-11 17:34:48 +0000471 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000472 <a href="http://validator.w3.org/check/referer"><img
Misha Brukmanf00ddb02008-12-11 18:23:24 +0000473 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000474
475 <a href="mailto:criswell@uiuc.edu">John Criswell</a><br>
NAKAMURA Takumib9a33632011-04-09 02:13:37 +0000476 <a href="http://llvm.org/">The LLVM Compiler Infrastructure</a>
Misha Brukmanf6a04072004-05-12 20:57:43 +0000477 <br>
478 Last modified: $Date$
479</address>
Misha Brukman733adcb2003-10-30 01:23:40 +0000480
John Criswellf2413ae2003-07-03 15:37:52 +0000481</body>
482</html>