Add a note about the removal of the atomic intrinsics to the "Major Changes" section...
[oota-llvm.git] / docs / Projects.html
index ecdb35b54c6c4d6a5570ea69a493caf5dd10bdad..910ebdb426db2c7846ec2901138620eb165259f8 100644 (file)
@@ -7,7 +7,7 @@
 </head>
 <body>
 
-<div class="doc_title">Creating an LLVM Project</div>
+<h1>Creating an LLVM Project</h1>
 
 <ol>
 <li><a href="#overview">Overview</a></li>
 </div>
 
 <!-- *********************************************************************** -->
-<div class="doc_section"><a name="overview">Overview</a></div>
+<h2><a name="overview">Overview</a></h2>
 <!-- *********************************************************************** -->
 
-<div class="doc_text">
+<div>
 
 <p>The LLVM build system is designed to facilitate the building of third party
 projects that use LLVM header files, libraries, and tools.  In order to use
 these facilities, a Makefile from a project must do the following things:</p>
 
 <ol>
-<li>Set environment variables.There are several environment variables that a
-Makefile needs to set to use the LLVM build system:
-
-<ul>
-  <li><tt>LLVM_SRC_ROOT</tt> - The root of the LLVM source tree.</li>
-  <li><tt>LLVM_OBJ_ROOT</tt> - The root of the LLVM object tree.</li>
-  <li><tt>BUILD_SRC_ROOT</tt> - The root of the project's source tree.</li>
-  <li><tt>BUILD_OBJ_ROOT</tt> - The root of the project's object tree.</li>
-  <li><tt>BUILD_SRC_DIR</tt> - The directory containing the current source to be
-  compiled.</li>
-  <li><tt>BUILD_OBJ_DIR</tt> - The directory where the current source will place
-  the new object files.  This should always be the current directory.</li>
-  <li><tt>LEVEL</tt> - The relative path from the current directory to the root
-  of the object tree.</li>
-</ul></li>
-<li>Include <tt>Makefile.config</tt> from <tt>$(LLVM_OBJ_ROOT)</tt>.</li>
-<li>Include <tt>Makefile.rules</tt> from <tt>$(LLVM_SRC_ROOT)</tt>.</li>
+  <li>Set <tt>make</tt> variables. There are several variables that a Makefile
+  needs to set to use the LLVM build system:
+  <ul>
+    <li><tt>PROJECT_NAME</tt> - The name by which your project is known.</li>
+    <li><tt>LLVM_SRC_ROOT</tt> - The root of the LLVM source tree.</li>
+    <li><tt>LLVM_OBJ_ROOT</tt> - The root of the LLVM object tree.</li>
+    <li><tt>PROJ_SRC_ROOT</tt> - The root of the project's source tree.</li>
+    <li><tt>PROJ_OBJ_ROOT</tt> - The root of the project's object tree.</li>
+    <li><tt>PROJ_INSTALL_ROOT</tt> - The root installation directory.</li>
+    <li><tt>LEVEL</tt> - The relative path from the current directory to the
+    project's root ($PROJ_OBJ_ROOT).</li>
+  </ul></li>
+  <li>Include <tt>Makefile.config</tt> from <tt>$(LLVM_OBJ_ROOT)</tt>.</li>
+  <li>Include <tt>Makefile.rules</tt> from <tt>$(LLVM_SRC_ROOT)</tt>.</li>
 </ol>
 
 <p>There are two ways that you can set all of these variables:</p>
-
 <ol>
-<li>You can write your own Makefiles which hard-code these values.</li>
-
-<li> You can use the pre-made LLVM sample project.  This sample project includes
-Makefiles, a configure script that can be used to configure the location of
-LLVM, and the ability to support multiple object directories from a single
-source directory.</li>
+  <li>You can write your own Makefiles which hard-code these values.</li>
+  <li>You can use the pre-made LLVM sample project. This sample project
+  includes Makefiles, a configure script that can be used to configure the
+  location of LLVM, and the ability to support multiple object directories
+  from a single source directory.</li>
 </ol>
 
-<p>This document assumes that you will base your project off of the LLVM sample
+<p>This document assumes that you will base your project on the LLVM sample
 project found in <tt>llvm/projects/sample</tt>.  If you want to devise your own
 build system, studying the sample project and LLVM Makefiles will probably
 provide enough information on how to write your own Makefiles.</p>
@@ -78,12 +73,12 @@ provide enough information on how to write your own Makefiles.</p>
 </div>
 
 <!-- *********************************************************************** -->
-<div class="doc_section">
+<h2>
   <a name="create">Create a Project from the Sample Project</a>
-</div>
+</h2>
 <!-- *********************************************************************** -->
 
-<div class="doc_text">
+<div>
 
 <p>Follow these simple steps to start your project:</p>
 
@@ -92,51 +87,70 @@ provide enough information on how to write your own Makefiles.</p>
 choosing.  You can place it anywhere you like.  Rename the directory to match
 the name of your project.</li>
 
+<li>
+If you downloaded LLVM using Subversion, remove all the directories named .svn
+(and all the files therein) from your project's new source tree.  This will
+keep Subversion from thinking that your project is inside
+<tt>llvm/trunk/projects/sample</tt>.</li>
+
 <li>Add your source code and Makefiles to your source tree.</li>
 
-<li>If you want your Makefiles to be configured by the <tt>configure</tt>
-script, or if you want to support multiple object directories, add your
-Makefiles to the <tt>configure</tt> script by adding them into the
-<tt>autoconf/configure.ac</tt> file.  The macro <tt>AC_CONFIG_MAKEFILE</tt> will
-copy a file, unmodified, from the source directory to the object directory.</li>
+<li>If you want your project to be configured with the <tt>configure</tt> script
+then you need to edit <tt>autoconf/configure.ac</tt> as follows:
+  <ul>
+    <li><b>AC_INIT</b>. Place the name of your project, its version number and
+    a contact email address for your project as the arguments to this macro</li>
+    <li><b>AC_CONFIG_AUX_DIR</b>. If your project isn't in the
+    <tt>llvm/projects</tt> directory then you might need to adjust this so that
+    it specifies a relative path to the <tt>llvm/autoconf</tt> directory.</li>
+    <li><b>LLVM_CONFIG_PROJECT</b>. Just leave this alone.</li>
+    <li><b>AC_CONFIG_SRCDIR</b>. Specify a path to a file name that identifies
+    your project; or just leave it at <tt>Makefile.common.in</tt></li>
+    <li><b>AC_CONFIG_FILES</b>. Do not change.</li>
+    <li><b>AC_CONFIG_MAKEFILE</b>. Use one of these macros for each Makefile
+    that your project uses. This macro arranges for your makefiles to be copied
+    from the source directory, unmodified, to the build directory.</li>
+  </ul>
+</li>
 
 <li>After updating <tt>autoconf/configure.ac</tt>, regenerate the
 configure script with these commands:
 
 <div class="doc_code">
 <p><tt>% cd autoconf<br>
-       % autoconf -o ../configure</tt></p>
+       % ./AutoRegen.sh</tt></p>
 </div>
 
-<p>You must be using Autoconf version 2.57 or higher.</p></li>
+<p>You must be using Autoconf version 2.59 or later and your aclocal version
+should be 1.9 or later.</p></li>
 
 <li>Run <tt>configure</tt> in the directory in which you want to place
 object code.  Use the following options to tell your project where it
 can find LLVM:
 
   <dl>
-    <dt><tt>--with-llvmsrc=&lt;directory&gt;</tt>
-    <dd>
-    Tell your project where the LLVM source tree is located.
-    <p>
-    <dt><tt>--with-llvmobj=&lt;directory&gt;</tt>
-    <dd>
-    Tell your project where the LLVM object tree is located.
+    <dt><tt>--with-llvmsrc=&lt;directory&gt;</tt></dt>
+    <dd>Tell your project where the LLVM source tree is located.</dd>
+    <dt><br><tt>--with-llvmobj=&lt;directory&gt;</tt></dt>
+    <dd>Tell your project where the LLVM object tree is located.</dd>
+    <dt><br><tt>--prefix=&lt;directory&gt;</tt></dt>
+    <dd>Tell your project where it should get installed.</dd>
   </dl>
 </ol>
 
-<p>That's it!  Now all you have to do is type <tt>gmake</tt> in the root of
-your object directory, and your project should build.</p>
+<p>That's it!  Now all you have to do is type <tt>gmake</tt> (or <tt>make</tt>
+if your on a GNU/Linux system) in the root of your object directory, and your
+project should build.</p>
 
 </div>
 
 <!-- *********************************************************************** -->
-<div class="doc_section">
+<h2>
   <a name="source">Source Tree Layout</a>
-</div>
+</h2>
 <!-- *********************************************************************** -->
 
-<div class="doc_text">
+<div>
 
 <p>In order to use the LLVM build system, you will want to organize your
 source code so that it can benefit from the build system's features.
@@ -186,30 +200,25 @@ directories:</p>
   This subdirectory should contain tests that verify that your code
   works correctly.  Automated tests are especially useful.
   <p>
-  Currently, the LLVM build system provides little support for tests,
-  although some exists.  Expanded support for tests will hopefully
-  occur in the future.  In the meantime, the LLVM system does provide the
-  following:
+  Currently, the LLVM build system provides basic support for tests.
+  The LLVM system provides the following:
   <ul>
     <li>
-    LLVM provides several QMTest test classes that can be used to
-    create tests.  They can be found in
-    <tt>llvm/test/QMTest/llvm.py</tt>.  These test classes perform a
-    variety of functions, including code optimization tests, assembly
-    tests,  and code analysis tests.  The Makefile in
-    <tt>llvm/test</tt> provides the QMTest context needed by LLVM test
-    classes.
-    <p>
-
+    LLVM provides a tcl procedure that is used by Dejagnu to run
+    tests.  It can be found in <tt>llvm/lib/llvm-dg.exp</tt>.  This
+    test procedure uses RUN lines in the actual test case to determine
+    how to run the test.  See the <a
+    href="TestingGuide.html">TestingGuide</a> for more details. You
+    can easily write Makefile support similar to the Makefiles in
+    <tt>llvm/test</tt> to use Dejagnu to run your project's tests.<br></li>
     <li>
-    The LLVM source tree provides benchmarks and programs which are
-    known to compile with the LLVM GCC front ends.  You can use these
+    LLVM contains an optional package called <tt>llvm-test</tt>
+    which provides benchmarks and programs that are known to compile with the
+    LLVM GCC front ends.  You can use these
     programs to test your code, gather statistics information, and
-    compare it to the current LLVM performance statistics.  These
-    programs are found in the <tt>llvm/test/Programs</tt> directory.
-    <p>
-    Currently, there is no way to hook your tests directly into the
-    <tt>llvm/test/Programs</tt> testing harness.  You will simply
+    compare it to the current LLVM performance statistics.
+    <br>Currently, there is no way to hook your tests directly into the
+    <tt>llvm/test</tt> testing harness.  You will simply
     need to find a way to use the source provided within that directory
     on your own.
   </ul>
@@ -221,26 +230,24 @@ your <b>tools</b> directory.</p>
 </div>
 
 <!-- *********************************************************************** -->
-<div class="doc_section">
+<h2>
   <a name="makefiles">Writing LLVM Style Makefiles</a>
-</div>
+</h2>
 <!-- *********************************************************************** -->
 
-<div class="doc_text">
+<div>
 
 <p>The LLVM build system provides a convenient way to build libraries and
 executables.  Most of your project Makefiles will only need to define a few
 variables.  Below is a list of the variables one can set and what they can
 do:</p>
 
-</div>
-
 <!-- ======================================================================= -->
-<div class="doc_subsection">
+<h3>
   <a name="reqVars">Required Variables</a>
-</div>
+</h3>
 
-<div class="doc_text">
+<div>
 
 <dl>
   <dt>LEVEL
@@ -254,11 +261,11 @@ do:</p>
 </div>
 
 <!-- ======================================================================= -->
-<div class="doc_subsection">
+<h3>
   <a name="varsBuildDir">Variables for Building Subdirectories</a>
-</div>
+</h3>
 
-<div class="doc_text">
+<div>
 
 <dl>
   <dt>DIRS
@@ -285,11 +292,11 @@ do:</p>
 </div>
 
 <!-- ======================================================================= -->
-<div class="doc_subsection">
+<h3>
   <a name="varsBuildLib">Variables for Building Libraries</a>
-</div>
+</h3>
 
-<div class="doc_text">
+<div>
 
 <dl>
   <dt>LIBRARYNAME
@@ -316,11 +323,11 @@ do:</p>
 </div>
 
 <!-- ======================================================================= -->
-<div class="doc_subsection">
+<h3>
   <a name="varsBuildProg">Variables for Building Programs</a>
-</div>
+</h3>
 
-<div class="doc_text">
+<div>
 
 <dl>
   <dt>TOOLNAME
@@ -332,16 +339,41 @@ do:</p>
 
   <dt>USEDLIBS
   <dd>
-  This variable holds a space separated list of libraries that
-  should be linked into the program.  These libraries must either
-  be LLVM libraries or libraries that come from your <b>lib</b>
-  directory.  The libraries must be specified by their base name.
-  For example, to link libsample.a, you would set USEDLIBS to
-  <tt>sample</tt>.
+  This variable holds a space separated list of libraries that should
+  be linked into the program.  These libraries must be libraries that
+  come from your <b>lib</b> directory.  The libraries must be
+  specified without their "lib" prefix.  For example, to link
+  libsample.a, you would set USEDLIBS to
+  <tt>sample.a</tt>.
   <p>
   Note that this works only for statically linked libraries.
   <p>
 
+  <dt>LLVMLIBS
+  <dd>
+  This variable holds a space separated list of libraries that should
+  be linked into the program.  These libraries must be LLVM libraries.
+  The libraries must be specified without their "lib" prefix.  For
+  example, to link with a driver that performs an IR transformation
+  you might set LLVMLIBS to this minimal set of libraries
+  <tt>LLVMSupport.a LLVMCore.a LLVMBitReader.a LLVMAsmParser.a LLVMAnalysis.a LLVMTransformUtils.a LLVMScalarOpts.a LLVMTarget.a</tt>.
+  <p>
+  Note that this works only for statically linked libraries. LLVM is
+  split into a large number of static libraries, and the list of libraries you
+  require may be much longer than the list above. To see a full list
+  of libraries use:
+  <tt>llvm-config --libs all</tt>.
+  Using LINK_COMPONENTS as described below, obviates the need to set LLVMLIBS.
+  <p>
+
+  <dt>LINK_COMPONENTS
+  <dd>This variable holds a space separated list of components that
+  the LLVM Makefiles pass to the <tt>llvm-config</tt> tool to generate
+  a link line for the program. For example, to link with all LLVM
+  libraries use
+  <tt>LINK_COMPONENTS = all</tt>.
+  <p>
+
   <dt>LIBS
   <dd>
   To link dynamic libraries, add <tt>-l&lt;library base name&gt;</tt> to
@@ -354,16 +386,19 @@ do:</p>
   <tt>
   LIBS += -lsample
   </tt>
+  <p>
+  Note that LIBS must occur in the Makefile after the inclusion of Makefile.common.
+  <p>
 </dl>
 
 </div>
 
 <!-- ======================================================================= -->
-<div class="doc_subsection">
+<h3>
   <a name="miscVars">Miscellaneous Variables</a>
-</div>
+</h3>
 
-<div class="doc_text">
+<div>
 
 <dl>
   <dt>ExtraSource
@@ -389,13 +424,15 @@ do:</p>
 
 </div>
 
+</div>
+
 <!-- *********************************************************************** -->
-<div class="doc_section">
+<h2>
   <a name="objcode">Placement of Object Code</a>
-</div>
+</h2>
 <!-- *********************************************************************** -->
 
-<div class="doc_text">
+<div>
 
 <p>The final location of built libraries and executables will depend upon
 whether you do a Debug, Release, or Profile build.</p>
@@ -404,13 +441,13 @@ whether you do a Debug, Release, or Profile build.</p>
   <dt>Libraries
   <dd>
   All libraries (static and dynamic) will be stored in
-  <tt>BUILD_OBJ_ROOT/lib/&lt;type&gt;</tt>, where type is <tt>Debug</tt>,
+  <tt>PROJ_OBJ_ROOT/&lt;type&gt;/lib</tt>, where type is <tt>Debug</tt>,
   <tt>Release</tt>, or <tt>Profile</tt> for a debug, optimized, or
   profiled build, respectively.<p>
 
   <dt>Executables
   <dd>All executables will be stored in
-  <tt>BUILD_OBJ_ROOT/tools/&lt;type&gt;</tt>, where type is <tt>Debug</tt>,
+  <tt>PROJ_OBJ_ROOT/&lt;type&gt;/bin</tt>, where type is <tt>Debug</tt>,
   <tt>Release</tt>, or <tt>Profile</tt> for a debug, optimized, or profiled
   build, respectively.
 </dl>
@@ -418,12 +455,12 @@ whether you do a Debug, Release, or Profile build.</p>
 </div>
 
 <!-- *********************************************************************** -->
-<div class="doc_section">
+<h2>
   <a name="help">Further Help</a>
-</div>
+</h2>
 <!-- *********************************************************************** -->
 
-<div class="doc_text">
+<div>
 
 <p>If you have any questions or need any help creating an LLVM project,
 the LLVM team would be more than happy to help.  You can always post your
@@ -432,17 +469,17 @@ href="http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev">LLVM Developers
 Mailing List</a>.</p>
 
 </div>
-  
+
 <!-- *********************************************************************** -->
 <hr>
 <address>
   <a href="http://jigsaw.w3.org/css-validator/check/referer"><img
-  src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+  src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS"></a>
   <a href="http://validator.w3.org/check/referer"><img
-  src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /></a>
+  src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"></a>
 
   <a href="mailto:criswell@uiuc.edu">John Criswell</a><br>
-  <a href="http://llvm.cs.uiuc.edu">The LLVM Compiler Infrastructure</a>
+  <a href="http://llvm.org/">The LLVM Compiler Infrastructure</a>
   <br>
   Last modified: $Date$
 </address>