blob: 54f747eea96f38bfbdbab5e5edd4f7f0df86fad6 [file] [log] [blame]
Misha Brukmane15655b2004-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 Criswell163110d2003-07-03 15:37:52 +00003<html>
Misha Brukmane15655b2004-05-12 20:57:43 +00004<head>
NAKAMURA Takumib8004d92011-10-31 11:21:59 +00005 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Misha Brukmane15655b2004-05-12 20:57:43 +00006 <title>Creating an LLVM Project</title>
Daniel Dunbar46d611a2012-04-19 20:20:34 +00007 <link rel="stylesheet" href="_static/llvm.css" type="text/css">
Misha Brukmane15655b2004-05-12 20:57:43 +00008</head>
9<body>
John Criswell163110d2003-07-03 15:37:52 +000010
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +000011<h1>Creating an LLVM Project</h1>
John Criswell163110d2003-07-03 15:37:52 +000012
Misha Brukmane15655b2004-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 Criswell163110d2003-07-03 15:37:52 +000028
Chris Lattner020e1fc2004-05-23 21:07:27 +000029<div class="doc_author">
30 <p>Written by John Criswell</p>
31</div>
32
Misha Brukmane15655b2004-05-12 20:57:43 +000033<!-- *********************************************************************** -->
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +000034<h2><a name="overview">Overview</a></h2>
Misha Brukmane15655b2004-05-12 20:57:43 +000035<!-- *********************************************************************** -->
John Criswell163110d2003-07-03 15:37:52 +000036
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +000037<div>
John Criswell5bd28dc2003-10-16 19:53:53 +000038
Misha Brukmane15655b2004-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 Criswell5bd28dc2003-10-16 19:53:53 +000042
Misha Brukmane15655b2004-05-12 20:57:43 +000043<ol>
Reid Spencer05a2e792005-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 Trick621129f02011-06-03 02:16:53 +000053 <li><tt>LEVEL</tt> - The relative path from the current directory to the
Reid Spencer05a2e792005-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 Brukmane15655b2004-05-12 20:57:43 +000058</ol>
John Criswell5bd28dc2003-10-16 19:53:53 +000059
Misha Brukmane15655b2004-05-12 20:57:43 +000060<p>There are two ways that you can set all of these variables:</p>
Misha Brukmane15655b2004-05-12 20:57:43 +000061<ol>
Reid Spencer05a2e792005-01-16 02:21:18 +000062 <li>You can write your own Makefiles which hard-code these values.</li>
Andrew Trick621129f02011-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 Spencer05a2e792005-01-16 02:21:18 +000066 from a single source directory.</li>
Misha Brukmane15655b2004-05-12 20:57:43 +000067</ol>
John Criswell5bd28dc2003-10-16 19:53:53 +000068
Reid Spencer05a2e792005-01-16 02:21:18 +000069<p>This document assumes that you will base your project on the LLVM sample
Misha Brukmane15655b2004-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 Criswell5bd28dc2003-10-16 19:53:53 +000073
Misha Brukmane15655b2004-05-12 20:57:43 +000074</div>
John Criswell5bd28dc2003-10-16 19:53:53 +000075
Misha Brukmane15655b2004-05-12 20:57:43 +000076<!-- *********************************************************************** -->
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +000077<h2>
Misha Brukmane15655b2004-05-12 20:57:43 +000078 <a name="create">Create a Project from the Sample Project</a>
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +000079</h2>
Misha Brukmane15655b2004-05-12 20:57:43 +000080<!-- *********************************************************************** -->
John Criswell5bd28dc2003-10-16 19:53:53 +000081
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +000082<div>
John Criswell5bd28dc2003-10-16 19:53:53 +000083
Misha Brukmane15655b2004-05-12 20:57:43 +000084<p>Follow these simple steps to start your project:</p>
John Criswell5bd28dc2003-10-16 19:53:53 +000085
Misha Brukmane15655b2004-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 Criswell5bd28dc2003-10-16 19:53:53 +000090
John Criswell6140e5d2005-10-24 16:43:08 +000091<li>
Andrew Trick621129f02011-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 Spencerc7f87f22007-07-09 08:04:31 +000095<tt>llvm/trunk/projects/sample</tt>.</li>
John Criswell6140e5d2005-10-24 16:43:08 +000096
Misha Brukmane15655b2004-05-12 20:57:43 +000097<li>Add your source code and Makefiles to your source tree.</li>
John Criswell5bd28dc2003-10-16 19:53:53 +000098
Reid Spencerda132f22005-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 Lattnerb96bf562006-03-16 16:14:59 +0000104 <li><b>AC_CONFIG_AUX_DIR</b>. If your project isn't in the
Reid Spencerda132f22005-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 Spencerdca24a12006-03-17 08:04:25 +0000109 your project; or just leave it at <tt>Makefile.common.in</tt></li>
Reid Spencerda132f22005-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 Criswell163110d2003-07-03 15:37:52 +0000116
Misha Brukmane15655b2004-05-12 20:57:43 +0000117<li>After updating <tt>autoconf/configure.ac</tt>, regenerate the
118configure script with these commands:
John Criswell163110d2003-07-03 15:37:52 +0000119
Misha Brukmane15655b2004-05-12 20:57:43 +0000120<div class="doc_code">
121<p><tt>% cd autoconf<br>
Dan Gohman87bc8002009-01-12 21:29:24 +0000122 % ./AutoRegen.sh</tt></p>
Misha Brukmane15655b2004-05-12 20:57:43 +0000123</div>
John Criswell163110d2003-07-03 15:37:52 +0000124
Misha Brukman952784f2009-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 Criswell5bd28dc2003-10-16 19:53:53 +0000127
Misha Brukmane15655b2004-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 Criswell5bd28dc2003-10-16 19:53:53 +0000131
Misha Brukmane15655b2004-05-12 20:57:43 +0000132 <dl>
Reid Spencerda132f22005-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 Brukman21a63702008-12-11 18:23:24 +0000135 <dt><br><tt>--with-llvmobj=&lt;directory&gt;</tt></dt>
Reid Spencerda132f22005-02-28 00:40:29 +0000136 <dd>Tell your project where the LLVM object tree is located.</dd>
Misha Brukman21a63702008-12-11 18:23:24 +0000137 <dt><br><tt>--prefix=&lt;directory&gt;</tt></dt>
Reid Spencerda132f22005-02-28 00:40:29 +0000138 <dd>Tell your project where it should get installed.</dd>
Misha Brukmane15655b2004-05-12 20:57:43 +0000139 </dl>
140</ol>
John Criswell5bd28dc2003-10-16 19:53:53 +0000141
Reid Spencerda132f22005-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 Trick621129f02011-06-03 02:16:53 +0000143if your on a GNU/Linux system) in the root of your object directory, and your
Reid Spencerda132f22005-02-28 00:40:29 +0000144project should build.</p>
John Criswell163110d2003-07-03 15:37:52 +0000145
Misha Brukmane15655b2004-05-12 20:57:43 +0000146</div>
John Criswell5bd28dc2003-10-16 19:53:53 +0000147
Misha Brukmane15655b2004-05-12 20:57:43 +0000148<!-- *********************************************************************** -->
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000149<h2>
Misha Brukmane15655b2004-05-12 20:57:43 +0000150 <a name="source">Source Tree Layout</a>
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000151</h2>
Misha Brukmane15655b2004-05-12 20:57:43 +0000152<!-- *********************************************************************** -->
John Criswell163110d2003-07-03 15:37:52 +0000153
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +0000154<div>
John Criswell5bd28dc2003-10-16 19:53:53 +0000155
Misha Brukmane15655b2004-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 Criswell163110d2003-07-03 15:37:52 +0000162
Misha Brukmane15655b2004-05-12 20:57:43 +0000163<p>Underneath your top level directory, you should have the following
164directories:</p>
John Criswell163110d2003-07-03 15:37:52 +0000165
Misha Brukmane15655b2004-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 Criswell163110d2003-07-03 15:37:52 +0000173
Misha Brukmane15655b2004-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 Criswell163110d2003-07-03 15:37:52 +0000179
Misha Brukmane15655b2004-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 Criswell163110d2003-07-03 15:37:52 +0000190
Misha Brukmane15655b2004-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 Criswell163110d2003-07-03 15:37:52 +0000198
Misha Brukmane15655b2004-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 Lattnere6ebbd72004-12-08 17:25:46 +0000204 Currently, the LLVM build system provides basic support for tests.
205 The LLVM system provides the following:
Misha Brukmane15655b2004-05-12 20:57:43 +0000206 <ul>
207 <li>
Tanya Lattnere6ebbd72004-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 Trick621129f02011-06-03 02:16:53 +0000213 can easily write Makefile support similar to the Makefiles in
Misha Brukman21a63702008-12-11 18:23:24 +0000214 <tt>llvm/test</tt> to use Dejagnu to run your project's tests.<br></li>
Misha Brukmane15655b2004-05-12 20:57:43 +0000215 <li>
John Criswelldfe6a862004-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 Brukmane15655b2004-05-12 20:57:43 +0000219 programs to test your code, gather statistics information, and
John Criswelldfe6a862004-12-10 15:51:16 +0000220 compare it to the current LLVM performance statistics.
Misha Brukman21a63702008-12-11 18:23:24 +0000221 <br>Currently, there is no way to hook your tests directly into the
John Criswelldfe6a862004-12-10 15:51:16 +0000222 <tt>llvm/test</tt> testing harness. You will simply
Misha Brukmane15655b2004-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 Criswellb920fe72003-10-21 19:35:06 +0000227
Misha Brukmane15655b2004-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 Criswell163110d2003-07-03 15:37:52 +0000230
Misha Brukmane15655b2004-05-12 20:57:43 +0000231</div>
John Criswell163110d2003-07-03 15:37:52 +0000232
Misha Brukmane15655b2004-05-12 20:57:43 +0000233<!-- *********************************************************************** -->
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000234<h2>
Misha Brukmane15655b2004-05-12 20:57:43 +0000235 <a name="makefiles">Writing LLVM Style Makefiles</a>
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000236</h2>
Misha Brukmane15655b2004-05-12 20:57:43 +0000237<!-- *********************************************************************** -->
John Criswell163110d2003-07-03 15:37:52 +0000238
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +0000239<div>
John Criswell163110d2003-07-03 15:37:52 +0000240
Misha Brukmane15655b2004-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 Criswell163110d2003-07-03 15:37:52 +0000245
Misha Brukmane15655b2004-05-12 20:57:43 +0000246<!-- ======================================================================= -->
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000247<h3>
Misha Brukmane15655b2004-05-12 20:57:43 +0000248 <a name="reqVars">Required Variables</a>
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000249</h3>
John Criswell163110d2003-07-03 15:37:52 +0000250
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +0000251<div>
John Criswell163110d2003-07-03 15:37:52 +0000252
Misha Brukmane15655b2004-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 Criswell163110d2003-07-03 15:37:52 +0000261
Misha Brukmane15655b2004-05-12 20:57:43 +0000262</div>
John Criswell163110d2003-07-03 15:37:52 +0000263
Misha Brukmane15655b2004-05-12 20:57:43 +0000264<!-- ======================================================================= -->
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000265<h3>
Misha Brukmane15655b2004-05-12 20:57:43 +0000266 <a name="varsBuildDir">Variables for Building Subdirectories</a>
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000267</h3>
John Criswell163110d2003-07-03 15:37:52 +0000268
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +0000269<div>
John Criswell91dbd8f2003-10-17 21:50:38 +0000270
Misha Brukmane15655b2004-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 Criswell163110d2003-07-03 15:37:52 +0000278
Misha Brukmane15655b2004-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 Criswell163110d2003-07-03 15:37:52 +0000285
Misha Brukmane15655b2004-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 Criswell163110d2003-07-03 15:37:52 +0000292
Misha Brukmane15655b2004-05-12 20:57:43 +0000293</div>
John Criswell5bd28dc2003-10-16 19:53:53 +0000294
Misha Brukmane15655b2004-05-12 20:57:43 +0000295<!-- ======================================================================= -->
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000296<h3>
Misha Brukmane15655b2004-05-12 20:57:43 +0000297 <a name="varsBuildLib">Variables for Building Libraries</a>
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000298</h3>
John Criswell5bd28dc2003-10-16 19:53:53 +0000299
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +0000300<div>
John Criswell5bd28dc2003-10-16 19:53:53 +0000301
Misha Brukmane15655b2004-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 Criswell5bd28dc2003-10-16 19:53:53 +0000310
Misha Brukmane15655b2004-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 Criswell5bd28dc2003-10-16 19:53:53 +0000317
Misha Brukmane15655b2004-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 Takumifc8d9302011-04-18 23:59:50 +0000327<h3>
Misha Brukmane15655b2004-05-12 20:57:43 +0000328 <a name="varsBuildProg">Variables for Building Programs</a>
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000329</h3>
Misha Brukmane15655b2004-05-12 20:57:43 +0000330
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +0000331<div>
Misha Brukmane15655b2004-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 Trickc71224e2011-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 Brukmane15655b2004-05-12 20:57:43 +0000349 <p>
350 Note that this works only for statically linked libraries.
351 <p>
352
Andrew Trickc71224e2011-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 Brukmane15655b2004-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 Trickc71224e2011-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 Brukmane15655b2004-05-12 20:57:43 +0000393</dl>
394
395</div>
396
397<!-- ======================================================================= -->
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000398<h3>
Misha Brukmane15655b2004-05-12 20:57:43 +0000399 <a name="miscVars">Miscellaneous Variables</a>
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000400</h3>
Misha Brukmane15655b2004-05-12 20:57:43 +0000401
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +0000402<div>
Misha Brukmane15655b2004-05-12 20:57:43 +0000403
404<dl>
405 <dt>ExtraSource
406 <dd>
407 This variable contains a space separated list of extra source
408 files that need to be built. It is useful for including the
409 output of Lex and Yacc programs.
410 <p>
411
412 <dt>CFLAGS
413 <dt>CPPFLAGS
414 <dd>
415 This variable can be used to add options to the C and C++
416 compiler, respectively. It is typically used to add options
417 that tell the compiler the location of additional directories
418 to search for header files.
419 <p>
420 It is highly suggested that you append to CFLAGS and CPPFLAGS as
421 opposed to overwriting them. The master Makefiles may already
422 have useful options in them that you may not want to overwrite.
423 <p>
424</dl>
425
426</div>
427
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +0000428</div>
429
Misha Brukmane15655b2004-05-12 20:57:43 +0000430<!-- *********************************************************************** -->
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000431<h2>
Misha Brukmane15655b2004-05-12 20:57:43 +0000432 <a name="objcode">Placement of Object Code</a>
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000433</h2>
Misha Brukmane15655b2004-05-12 20:57:43 +0000434<!-- *********************************************************************** -->
435
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +0000436<div>
Misha Brukmane15655b2004-05-12 20:57:43 +0000437
438<p>The final location of built libraries and executables will depend upon
439whether you do a Debug, Release, or Profile build.</p>
440
441<dl>
442 <dt>Libraries
443 <dd>
444 All libraries (static and dynamic) will be stored in
Reid Spencer64cee422005-01-16 02:38:06 +0000445 <tt>PROJ_OBJ_ROOT/&lt;type&gt;/lib</tt>, where type is <tt>Debug</tt>,
Misha Brukmane15655b2004-05-12 20:57:43 +0000446 <tt>Release</tt>, or <tt>Profile</tt> for a debug, optimized, or
447 profiled build, respectively.<p>
448
449 <dt>Executables
450 <dd>All executables will be stored in
Reid Spencer64cee422005-01-16 02:38:06 +0000451 <tt>PROJ_OBJ_ROOT/&lt;type&gt;/bin</tt>, where type is <tt>Debug</tt>,
Misha Brukmane15655b2004-05-12 20:57:43 +0000452 <tt>Release</tt>, or <tt>Profile</tt> for a debug, optimized, or profiled
453 build, respectively.
454</dl>
455
456</div>
457
458<!-- *********************************************************************** -->
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000459<h2>
Misha Brukmane15655b2004-05-12 20:57:43 +0000460 <a name="help">Further Help</a>
NAKAMURA Takumifc8d9302011-04-18 23:59:50 +0000461</h2>
Misha Brukmane15655b2004-05-12 20:57:43 +0000462<!-- *********************************************************************** -->
463
NAKAMURA Takumiaa3d6242011-04-23 00:30:22 +0000464<div>
Misha Brukmane15655b2004-05-12 20:57:43 +0000465
466<p>If you have any questions or need any help creating an LLVM project,
467the LLVM team would be more than happy to help. You can always post your
468questions to the <a
469href="http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev">LLVM Developers
470Mailing List</a>.</p>
471
472</div>
Andrew Trick621129f02011-06-03 02:16:53 +0000473
Misha Brukmane15655b2004-05-12 20:57:43 +0000474<!-- *********************************************************************** -->
John Criswell5bd28dc2003-10-16 19:53:53 +0000475<hr>
Misha Brukmane15655b2004-05-12 20:57:43 +0000476<address>
477 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
Misha Brukman86242e12008-12-11 17:34:48 +0000478 src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
Misha Brukmane15655b2004-05-12 20:57:43 +0000479 <a href="http://validator.w3.org/check/referer"><img
Misha Brukman21a63702008-12-11 18:23:24 +0000480 src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
Misha Brukmane15655b2004-05-12 20:57:43 +0000481
482 <a href="mailto:criswell@uiuc.edu">John Criswell</a><br>
NAKAMURA Takumica46f5a2011-04-09 02:13:37 +0000483 <a href="http://llvm.org/">The LLVM Compiler Infrastructure</a>
Misha Brukmane15655b2004-05-12 20:57:43 +0000484 <br>
485 Last modified: $Date$
486</address>
Misha Brukmand8c3ba32003-10-30 01:23:40 +0000487
John Criswell163110d2003-07-03 15:37:52 +0000488</body>
489</html>