blob: f7cf48faddc7b5430f70a7ac9b80ffff771eae1c [file] [log] [blame]
Reid Spencer504b21a2004-10-23 07:57:22 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2<html>
3<head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <title>LLVM Makefile Guide</title>
6 <link rel="stylesheet" href="llvm.css" type="text/css">
7</head>
8<body>
9
10<div class="doc_title">LLVM Makefile Guide</div>
11
12<ol>
13 <li><a href="#introduction">Introduction</a></li>
14 <li><a href="#general">General Concepts</a>
15 <ol>
16 <li><a href="#projects">Projects</a></li>
17 <li><a href="#Makefile">Makefile</a></li>
18 <li><a href="#Makefile.common">Makefile.common</a></li>
19 <li><a href="#Makefile.config">Makefile.config</a></li>
20 <li><a href="#Makefile.rules">Makefil.rules</a></li>
21 <li><a href="#Comments">Comments</a></li>
22 </ol>
23 </li>
24 <li><a href="#targets">Targets Supported</a>
25 <ol>
26 <li><a href="#all">all</a></li>
27 <li><a href="#all-local">all-local</a></li>
28 <li><a href="#check">check</a></li>
29 <li><a href="#check-local">check-local</a></li>
30 <li><a href="#clean">clean</a></li>
31 <li><a href="#clean-local">clean-local</a></li>
32 <li><a href="#dist">dist</a></li>
33 <li><a href="#dist-check">dist-check</a></li>
34 <li><a href="#dist-clean">dist-clean</a></li>
35 <li><a href="#install">install</a></li>
36 <li><a href="#tags">tags</a></li>
37 <li><a href="#uninstall">uninstall</a></li>
38 </ol>
39 </li>
40 <li><a href="#variables">Using Variables</a>
41 <ol>
42 <li><a href="#setvars">Control Variables</a></li>
43 <li><a href="#overvars">Override Variables</a></li>
44 <li><a href="#getvars">Readable Variables</a></li>
45 </ol>
46 </li>
47</ol>
48
49<div class="doc_author">
50 <p>Written by <a href="mailto:reid@x10sys.com">Reid Spencer</a></p>
51</div>
52
53<!-- *********************************************************************** -->
54<div class="doc_section"><a name="introduction">Introduction </a></div>
55<!-- *********************************************************************** -->
56
57<div class="doc_text">
58 <p>This document provides <em>usage</em> information about the LLVM makefile
59 system. While loosely patterned after the BSD makefile system, LLVM has taken
60 a deparature from BSD in order to implement additional features needed by LLVM.
61 </p>
62 <p>Although makefile systems such as automake were attempted at one point, it
63 has become clear that the variations requried by LLVM from any Makefle norm
64 are too many to strictly use a more limited tool. Consequently, LLVM requires
65 simply GNU Make 3.79, a widely portably makefile processor. LLVM unabashedly
66 makes heavy use of the features of GNU Make so the dependency on GNU Make is
67 firm. If you're not familiar with <tt>make</tt>, it is recommended that you
68 read the <a href="http://www.gnu.org/software/make/manual/make.html">
69 GNU Makefile Manual</a>.</p>
70 <p>While this document is rightly part of the
71 <a href="ProgrammersManual.html">LLVM Programmer's Manual</a>, it is treated
72 separately here because of the volume of content and because it is often an
73 early source of bewilderment for new developers.</p>
74</div>
75
76<!-- *********************************************************************** -->
77<div class="doc_section"><a name="general">General Concepts</a></div>
78<!-- *********************************************************************** -->
79
80<div class="doc_text">
81 <p>The LLVM makefile system is the component of LLVM that is responsible for
82 building the software, testing it, generating distributions, rpms and other
83 packages, installing and uninstalling, etc.</p>
84</div>
85
86<!-- ======================================================================= -->
87<div class="doc_subsection"><a name="projects">Projects</a></div>
88<div class="doc_text">
89 <p>The LLVM Makefile System is quite generous. It not only builds its own
90 software, but it can build yours too. Built into the system is knowledge of
91 the <tt>llvm/projects</tt> directory. Any directory under <tt>projects</tt>
92 that has both a <tt>configure</tt> script and a <tt>Makefile</tt> is assumed
93 to be a project that uses the LLVM Makefile system. This allows your project
94 to get up and running quickly by utilizing the built-in features that are used
95 to compile LLVM.</p>
96</div>
97
98<!-- ======================================================================= -->
99<div class="doc_subsection"><a name="Makefile">Makefile</a></div>
100<div class="doc_text">
101 <p>Each directory to participate in the build needs to have a file named
102 <tt>Makefile</tt>. This is the file first read by <tt>make</tt>. It has three
103 sections:</p>
104 <ol>
105 <li><a href="setvars">Settable Variables</a> - Required that must be set
106 first.</li>
107 <li><a href="Makefile.common">include <tt>$(LEVEL)/Makefile.common</tt></a>
108 - include the LLVM Makefile system.
109 <li><a href="overvars">Overridable Variables</a> - Override variables set by
110 the LLVM Makefile system.
111 </ol>
112</div>
113
114<!-- ======================================================================= -->
115<div class="doc_subsection"><a name="Makefile.common">Makefile.common</a></div>
116<div class="doc_text">
117 <p>Every project must have a <tt>Makefile.common</tt> file at its top source
118 directory. This file serves three purposes:</p>
119 <ol>
120 <li>It includes the project's configuration makefile to obtain values
121 determined by the <tt>configure</tt> script. This is done by including the
122 <a href="Makefile.config"><tt>$(LEVEL)/Makefile.config</tt></a> file.</li>
123 <li>It specifies any other (static) values that are needed throughout the
124 project. Only values that are used in all or a large proportion of the
125 project's directories should be placed here.</li>
126 <li>It include's the standard rules for the LLVM Makefile system,
127 <a href="Makefile.rules"><tt>$(LLVM_SRC_ROOT)/Makefile.rules</tt></a>.
128 This file is the "guts" of the LLVM Makefile system.</li>
129 </ol>
130</div>
131
132<!-- ======================================================================= -->
133<div class="doc_subsection"><a name="Makefile.config">Makefile.config</a></div>
134<div class="doc_text">
135 <p>Every project must have a <tt>Makefile.config</tt> at the top of its
136 <em>build</em> directory. This file is <b>generated</b> by the
137 <tt>configure</tt> script from the pattern provided by the
138 <tt>Makefile.config.in</tt> file located at the top of the project's
139 <em>source</em> directory. The contents of this file depend largely on what
140 configuration items the project uses, however most projects can get what they
141 need by just relying on LLVM's configuration found in
142 <tt>$(LLVM_OBJ_ROOT)/Makefile.config</tt>.
143</div>
144
145<!-- ======================================================================= -->
146<div class="doc_subsection"><a name="Makefile.rules">Makefile.rules</a></div>
147<div class="doc_text">
148 <p>This file, located at <tt>$(LLVM_SRC_ROOT)/Makefile.rules</tt> is the heart
149 of the LLVM Makefile System. It provides all the logic, dependencies, and
150 rules for building the targets supported by the system. What it does largely
151 depends on the values of <tt>make</tt> <a href="variables">variables</a> that
152 have been set <em>before</em> <tt>Makefile.rules</tt> is included.
153</div>
154
155<!-- ======================================================================= -->
156<div class="doc_subsection"><a name="Comments">Comments</a></div>
157<div class="doc_text">
158 <p>User Makefiles need not have comments in them unless the construction is
159 unusual or it doesn't strictly follow the rules and patterns of the LLVM
160 makefile system. Makefile comments are invoked with the pound (#) character.
161 The # character and any text following it, to the end of the line, are ignored
162 by <tt>make</tt>.</p>
163</div>
164
165<!-- *********************************************************************** -->
166<div class="doc_section"><a name="targets">Targets Supported</a></div>
167<!-- *********************************************************************** -->
168
169<div class="doc_text">
170 <p>This section describes each of the targets that can be built using the LLVM
171 Makefile system. Any target can be invoked from any directory but not all are
172 applicabe to a given directory (e.g. "dist" and "install" will always operate
173 as if invoked from the top level directory).</p>
174
175 <table style="text-align:left">
176 <tr><th>Target Name</th><th>Implied Targets</th><th>Target Description</th></tr>
177 <tr><td><a href="#all"><tt>all</tt></td><td></td>
178 <td>Compile the software recursively. Default target.
179 </td></tr>
180 <tr><td><a href="#all-local"><tt>all-local</tt></td><td></td>
181 <td>Compile the software in the local directory only.
182 </td></tr>
183 <tr><td><a href="#check"><tt>check</tt></td><td>all</td>
184 <td>Test the software recursively.
185 </td></tr>
186 <tr><td><a href="#check-local"><tt>check-local</tt></td><td>all-local</td>
187 <td>Test the software in the local directory only.
188 </td></tr>
189 <tr><td><a href="#clean"><tt>clean</tt></td><td></td>
190 <td>Remove built objects recursively.
191 </td></tr>
192 <tr><td><a href="#clean-local"><tt>clean-local</tt></td><td></td>
193 <td>Remove built objects from the local directory only.
194 </td></tr>
195 <tr><td><a href="#dist"><tt>dist</tt></td><td>all</td>
196 <td>Prepare a source distribution tarball.
197 </td></tr>
198 <tr><td><a href="#dist-check"><tt>dist-check</tt></td><td>all check</td>
199 <td>Prepare a source distribution tarball and check that it builds.
200 </td></tr>
201 <tr><td><a href="#dist-clean"><tt>dist-clean</tt></td><td>clean</td>
202 <td>Clean source distribution tarball temporary files.
203 </td></tr>
204 <tr><td><a href="#install"><tt>install</tt></td><td>all</td>
205 <td>Copy built objects to installation directory.
206 </td></tr>
207 <tr><td><a href="#tags"><tt>tags</tt></td><td></td>
208 <td>Make C and C++ tags files for emacs and vi.
209 </td></tr>
210 <tr><td><a href="#uninstall"><tt>uninstall</tt></td><td></td>
211 <td>Remove built objects from installation directory.
212 </td></tr>
213 </table>
214</div>
215
216<!-- ======================================================================= -->
217<div class="doc_subsection"><a name="all">all (default)</a></div>
218<div class="doc_text">
219 <p>When you invoke <tt>make</tt> with no arguments, you are implicitly
220 instructing it to seek the "all" target (goal). This target is used for
221 building the software and will do different things in different directories.
222 For example, in a <tt>lib</tt> directory, the "all" target will compile source
223 files and generate libraries. But, in a <tt>tools</tt> directory, it will link
224 libraries and generate executables.</p>
225</div>
226
227<!-- ======================================================================= -->
228<div class="doc_subsection"><a name="all-local">all-local</a></div>
229<div class="doc_text">
230 <p>TBD</p>
231</div>
232
233<!-- ======================================================================= -->
234<div class="doc_subsection"><a name="check">check</a></div>
235<div class="doc_text">
236 <p>TBD</p>
237</div>
238
239<!-- ======================================================================= -->
240<div class="doc_subsection"><a name="check-local">check-local</a></div>
241<div class="doc_text">
242 <p>TBD</p>
243</div>
244
245<!-- ======================================================================= -->
246<div class="doc_subsection"><a name="clean">clean</a></div>
247<div class="doc_text">
248 <p>TBD</p>
249</div>
250
251<!-- ======================================================================= -->
252<div class="doc_subsection"><a name="clean-local">clean-local</a></div>
253<div class="doc_text">
254 <p>TBD</p>
255</div>
256
257<!-- ======================================================================= -->
258<div class="doc_subsection"><a name="dist">dist</a></div>
259<div class="doc_text">
260 <p>TBD</p>
261</div>
262
263<!-- ======================================================================= -->
264<div class="doc_subsection"><a name="dist-check">dist-check</a></div>
265<div class="doc_text">
266 <p>TBD</p>
267</div>
268
269<!-- ======================================================================= -->
270<div class="doc_subsection"><a name="dist-clean">dist-clean</a></div>
271<div class="doc_text">
272 <p>TBD</p>
273</div>
274
275<!-- ======================================================================= -->
276<div class="doc_subsection"><a name="install">install</a></div>
277<div class="doc_text">
278 <p>TBD</p>
279</div>
280<!-- ======================================================================= -->
281<div class="doc_subsection"><a name="tags">tags</a></div>
282<div class="doc_text">
283 <p>TBD</p>
284</div>
285
286<!-- ======================================================================= -->
287<div class="doc_subsection"><a name="uninstall">uninstall</a></div>
288<div class="doc_text">
289 <p>TBD</p>
290</div>
291
292<!-- *********************************************************************** -->
293<div class="doc_section"><a name="variables">Variables</a></div>
294<!-- *********************************************************************** -->
295<div class="doc_text">
296 <p>Variables are used to tell the LLVM Makefile System what to do and to
297 obtain information from it. The sections below describe the three kinds of
298 variables.</p>
299</div>
300
301<!-- ======================================================================= -->
302<div class="doc_subsection"><a name="setvars">Control Variables</a></div>
303<div class="doc_text">
304 <p>Variables listed in the table below should be set <em>before</em> the
305 inclusion of <a href="Makefile.common"><tt>$(LEVEL)/Makefile.common</tt></a>.
306 These variables provide input to the LLVM make system that tell it what to do
307 for the current directory.</p>
308 <table style="text-align:left">
309 <tr><th>Variable Name</th><th>Variable Description</th></tr>
310 <tr>
311 <td><a href="#BUILD_ARCHIVE"><tt>BUILD_ARCHIVE</tt></a></td>
312 <td>If set to any value, causes an archive (.a) library to be built.</td>
313 </tr><tr><td><a href="#BUILT_SOURCES"><tt>BUILT_SOURCES</tt></a></td>
314 <td>Specifies a set of source files that are generated. These will be
315 built before any other target processing to ensure they are present.</td>
316 </tr><tr><td><a href="#BYTECODE_LIBRARY"><tt>BUILT_SOURCES</tt></a></td>
317 <td>If set to any value, causes a bytecode library (.bc) to be built.</td>
318 </tr><tr><td><a href="#CONFIG_FILES"><tt>BUILT_SOURCES</tt></a></td>
319 <td>Specivies a set of configuration files to be installed.</td>
320 </tr><tr><td><a href="#DIRS"><tt>DIRS</tt></a></td>
321 <td>Specifies a set of directories that should also be made using the
322 same goal. These directories will be built serially.</td>
323 </tr><tr><td><a href="#DONT_BUILD_RELINKED"><tt>DONT_BUILD_RELINKED</tt></a></td>
324 <td>If set to any value, causes a relinked library (.o) not to be built.</td>
325 </tr><tr><td><a href="#EXPORTED_SYMBOL_FILE"><tt>EXPORTED_SYMBOL_FILE</tt></a></td>
326 <td>Specifies the name of a single file that contains a list of the
327 symbols to be exported by the linker. One symbol per line.</td>
328 </tr><tr><td><a href="#LEVEL"><tt>LEVEL</tt></a></td>
329 <td>Specify the level of nesting from the top level. (Required)</td>
330 </tr><tr><td><a href="#LIBRARYNAME"><tt>LIBRARYNAME</tt></a></td>
331 <td>Specify the name of the library to be built. (Required For Libraries)</td>
332 </tr><tr><td><a href="#LLVMLIBS"><tt>LLVMLIBS</tt></a></td>
333 <td>Specify the set of libraries from the LLVM $(OBJDIR) that will be
334 linked into the tool or library.</td>
335 </tr><tr><td><a href="#OPTIONAL_DIRS"><tt>OPTIONAL_DIRS</tt></a></td>
336 <td>Specify a set of directories that may be built, but if they don't
337 build, the recursive make doesn't stop.</td>
338 </tr><tr><td><a href="#PARALLEL_DIRS"><tt>PARALLEL_DIRS</tt></a></td>
339 <td>Specify a set of directories to build recursively and in parallel if
340 the -j option was used with <tt>make</tt>.</td>
341 </tr><tr><td><a href="#SHARED_LIBRARY"><tt>SHARED_LIBRARY</tt></a></td>
342 <td>If set to any value, causes a shared library (.so) to be built.
343 (Optional)</td>
344 </tr><tr><td><a href="#SOURCES"><tt>SOURCES</tt></a></td>
345 <td>Specifies the list of source files in the current directory to be
346 acted upon. Source files of any type may be specified (programs,
347 documentation, config files, etc.)</td>
348 </tr><tr><td><a href="#TARGET"><tt>TARGET</tt></a></td>
349 <td>Specifies the name of the LLVM code generation target that the
350 current directory builds.</td>
351 </tr><tr><td><a href="#TOOLNAME"><tt>TOOLNAME</tt></a></td>
352 <td>Specifies the name of the tool to build. (Required For Tools)</td>
353 </tr><tr><td><a href="#USEDLIBS"><tt>USEDLIBS</tt></a></td>
354 <td>Specifies the list of project libraries that will be linked into the
355 tool or library.</td>
356 </tr>
357 </table>
358</div>
359
360<!-- ======================================================================= -->
361<div class="doc_subsection"><a name="overvars">Overridable Variables</a></div>
362<div class="doc_text">
363 <p>Variables listed in the table below can be used to override the default
364 values provided by the LLVM makefile system. These variables should be set
365 <em>after</em> the inclusion of <a
366 href="Makefile.common"><tt>$(LEVEL)/Makefile.common</tt></a>.</p>
367 <table style="text-align:left">
368 <tr><th>Variable Name</th><th>Variable Description</th></tr>
369 <tr>
370 <td><a href="#C"><tt>C</tt></a></td>
371 <td>The name (and optional path) of the 'C' compiler (gcc normally).</td>
372 </tr>
373 <tr>
374 <td><a href="#CFLAGS"><tt>CFLAGS</tt></a></td>
375 <td>The set of options to be passed to the 'C' compiler on <em>every</em>
376 compile.</td>
377 </tr>
378 <tr>
379 <td><a href="#CPP"><tt>CPP</tt></a></td>
380 <td>The name (and optional path) of the 'C' pre-processor (cpp normally).
381 </td>
382 </tr>
383 <tr>
384 <td><a href="#CXX"><tt>CXX</tt></a></td>
385 <td>The name (and optional path) of the C++ compiler (g++ normally).</td>
386 </tr>
387 <tr>
388 <td><a href="#LD"><tt>LD</tt></a></td>
389 <td>The name (and optional path) of the system linker (gcc normally).</td>
390 </tr>
391 <tr>
392 <td><a href="#LIBTOOL"><tt>LIBTOOL</tt></a></td>
393 <td>The name (and optional path) of the libtool tool (libtool normally).</td>
394 </tr>
395 </table>
396</div>
397
398<!-- ======================================================================= -->
399<div class="doc_subsection"><a name="getvars">Readable Variables</a></div>
400<div class="doc_text">
401 <p>Variables listed in the table below can be used by the user's Makefile but
402 should not be changed. Changing the value will generally cause the build to go
403 wrong, so don't do it.</p>
404 <table style="text-align:left">
405 <tr><th>Variable Name</th><th>Variable Description</th></tr>
406 <tr>
407 <td><a href="#BUILD_SRC_DIR"><tt>BUILD_SRC_DIR</tt></a></td>
408 <td>The project directory contaning the directories source files.</td>
409 </tr>
410 <tr>
411 <td><a href="#BUILD_OBJ_DIR"><tt>BUILD_OBJ_DIR</tt></a></td>
412 <td>The project directory that will receive the object files.</td>
413 </tr>
414 <tr>
415 <td><a href="#DESTDIR"><tt>DESTDIR</tt></a></td>
416 <td>The top level directory into which files are installed.</td>
417 </tr>
418 <tr>
419 <td><a href="#LLVM_SRC_ROOT"><tt>LLVM_SRC_ROOT</tt></a></td>
420 <td>The top level directory of the LLVM source.</td>
421 </tr>
422 <tr>
423 <td><a href="#LLVM_OBJ_ROOT"><tt>LLVM_OBJ_ROOT</tt></a></td>
424 <td>The top level directory of the LLVM objects.</td>
425 </tr>
426 <tr>
427 <td><a href="#OBJDIR"><tt>OBJDIR</tt></a></td>
428 <td>The directory in which the project's object files should be placed.</td>
429 </tr>
430 <tr>
431 <td><a href="#LIBDIR"><tt>LIBDIR</tt></a></td>
432 <td>The directory in which the project's library files should be placed.</td>
433 </tr>
434 <tr>
435 <td><a href="#TOOLDIR"><tt>TOOLDIR</tt></a></td>
436 <td>The directory in which the project's executable tools should be
437 placed.</td>
438 </tr>
439 </table>
440</div>
441
442<!-- *********************************************************************** -->
443<hr>
444<address>
445 <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
446 src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
447 <a href="http://validator.w3.org/check/referer"><img
448 src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a>
449
450 <a href="mailto:rspencer@x10sys.com">Reid Spencer</a><br>
451 <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a><br>
452 Last modified: $Date$
453</address>
454
455</body>
456</html>
457<!-- vim: sw=2 noai
458-->