X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FProjects.html;h=da4b06452b59c400e4a000438d748a72b0f7650f;hb=c352caf168094c83f05a8010ca14c2e643dbf618;hp=a937d3c368084613fda67cb9c954c291d9c2d94e;hpb=444087057ad0592f3e0bb2e434e0b610aa7914f6;p=oota-llvm.git diff --git a/docs/Projects.html b/docs/Projects.html index a937d3c3680..da4b06452b5 100644 --- a/docs/Projects.html +++ b/docs/Projects.html @@ -2,12 +2,13 @@ "http://www.w3.org/TR/html4/strict.dtd"> + Creating an LLVM Project -
Creating an LLVM Project
+

Creating an LLVM Project

  1. Overview
  2. @@ -30,10 +31,10 @@ -
    Overview
    +

    Overview

    -
    +

    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 @@ -49,7 +50,7 @@ these facilities, a Makefile from a project must do the following things:

  3. PROJ_SRC_ROOT - The root of the project's source tree.
  4. PROJ_OBJ_ROOT - The root of the project's object tree.
  5. PROJ_INSTALL_ROOT - The root installation directory.
  6. -
  7. LEVEL - The relative path from the current directory to the +
  8. LEVEL - The relative path from the current directory to the project's root ($PROJ_OBJ_ROOT).
  9. Include Makefile.config from $(LLVM_OBJ_ROOT).
  10. @@ -59,9 +60,9 @@ these facilities, a Makefile from a project must do the following things:

    There are two ways that you can set all of these variables:

    1. You can write your own Makefiles which hard-code these values.
    2. -
    3. 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 +
    4. 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.
    @@ -73,12 +74,12 @@ provide enough information on how to write your own Makefiles.

    - + -
    +

    Follow these simple steps to start your project:

    @@ -88,9 +89,9 @@ choosing. You can place it anywhere you like. Rename the directory to match the name of your project.
  11. -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 +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 llvm/trunk/projects/sample.
  12. Add your source code and Makefiles to your source tree.
  13. @@ -118,11 +119,11 @@ configure script with these commands:

    % cd autoconf
    - % AutoRegen.sh

    + % ./AutoRegen.sh

    -

    You must be using Autoconf version 2.59 or later and your aclocal version -should 1.9 or later.

    +

    You must be using Autoconf version 2.59 or later and your aclocal version +should be 1.9 or later.

  14. Run configure in the directory in which you want to place object code. Use the following options to tell your project where it @@ -131,26 +132,26 @@ can find LLVM:
    --with-llvmsrc=<directory>
    Tell your project where the LLVM source tree is located.
    -

    --with-llvmobj=<directory>
    +

    --with-llvmobj=<directory>
    Tell your project where the LLVM object tree is located.
    -

    --prefix=<directory>
    +

    --prefix=<directory>
    Tell your project where it should get installed.

That's it! Now all you have to do is type gmake (or make -if your on a GNU/Linux system) in the root of your object directory, and your +if your on a GNU/Linux system) in the root of your object directory, and your project should build.

-
+

Source Tree Layout -

+ -
+

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. @@ -209,15 +210,15 @@ directories:

test procedure uses RUN lines in the actual test case to determine how to run the test. See the TestingGuide for more details. You - can easily write Makefile support similar to the Makefiles in - llvm/test to use Dejagnu to run your project's tests.
+ can easily write Makefile support similar to the Makefiles in + llvm/test to use Dejagnu to run your project's tests.
  • LLVM contains an optional package called llvm-test 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. -
    Currently, there is no way to hook your tests directly into the +
    Currently, there is no way to hook your tests directly into the llvm/test testing harness. You will simply need to find a way to use the source provided within that directory on your own. @@ -230,26 +231,24 @@ your tools directory.

  • -
    +

    Writing LLVM Style Makefiles -

    + -
    +

    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:

    -
    - - + -
    +
    LEVEL @@ -263,11 +262,11 @@ do:

    - + -
    +
    DIRS @@ -294,11 +293,11 @@ do:

    - + -
    +
    LIBRARYNAME @@ -325,11 +324,11 @@ do:

    - + -
    +
    TOOLNAME @@ -341,16 +340,41 @@ do:

    USEDLIBS
    - 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 lib - directory. The libraries must be specified by their base name. - For example, to link libsample.a, you would set USEDLIBS to - sample. + 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 lib directory. The libraries must be + specified without their "lib" prefix. For example, to link + libsample.a, you would set USEDLIBS to + sample.a.

    Note that this works only for statically linked libraries.

    +

    LLVMLIBS +
    + 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 + LLVMSupport.a LLVMCore.a LLVMBitReader.a LLVMAsmParser.a LLVMAnalysis.a LLVMTransformUtils.a LLVMScalarOpts.a LLVMTarget.a. +

    + 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: + llvm-config --libs all. + Using LINK_COMPONENTS as described below, obviates the need to set LLVMLIBS. +

    + +

    LINK_COMPONENTS +
    This variable holds a space separated list of components that + the LLVM Makefiles pass to the llvm-config tool to generate + a link line for the program. For example, to link with all LLVM + libraries use + LINK_COMPONENTS = all. +

    +

    LIBS
    To link dynamic libraries, add -l<library base name> to @@ -363,16 +387,19 @@ do:

    LIBS += -lsample +

    + Note that LIBS must occur in the Makefile after the inclusion of Makefile.common. +

    - + -
    +
    ExtraSource @@ -398,13 +425,15 @@ do:

    +
    + - + -
    +

    The final location of built libraries and executables will depend upon whether you do a Debug, Release, or Profile build.

    @@ -427,12 +456,12 @@ whether you do a Debug, Release, or Profile build.

    - + -
    +

    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 @@ -441,17 +470,17 @@ href="http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev">LLVM Developers Mailing List.

    - +
    Valid CSS Valid HTML 4.01 + src="http://www.w3.org/Icons/valid-html401-blue" alt="Valid HTML 4.01"> John Criswell
    - The LLVM Compiler Infrastructure + The LLVM Compiler Infrastructure
    Last modified: $Date$