
These instructions assume that your current directory starts out as the
"callgrapher" directory within the package.


Building with CMake
==============================================

1. Create a new directory for building.
  e.g. mkdir ../callgrapherbuild

2. Change into the new directory.
  e.g. cd ../callgrapherbuild

3. Run CMake with the path to the LLVM source. For LLVM 3.5
and later, LLVM can be built with configure even if the callgrapher is built
with CMake.
  e.g. cmake -DLLVM_DIR=</path/to/LLVM/build>/share/llvm/cmake/ ../callgrapher

4. Run make inside the build directory.
  e.g. make

This produces a dynamic callgrapher tool called
tools/callgrapher/callgrapher and a library for printing out the
static call graph in lib/callgraphs/callgraphs.so.

Running the call graph printer:
e.g.
clang -g -c -emit-llvm ../callgrapher/test/simpletest.c -o calls.bc
tools/callgrapher/callgrapher calls.bc


Building with Autoconf / configure
==============================================

1. Download and build LLVM as per the standard instructions.
  (http://llvm.org/docs/GettingStarted.html#getting-started-quickly-a-summary)
  
2. Reconfigure the callgrapher project to let it know where you built LLVM.
  e.g.
  cd autoconf
  ./AutoRegen.sh
  <Enter the paths to the LLVM source and build directories when asked>
  cd ..

  NOTE:
  For Ubuntu with llvm 3.5 or later you can use e.g.:
  /usr/lib/llvm-3.5/build/

3. Create a new directory for building.
  e.g. mkdir ../callgrapherbuild

4. Change into the new directory.
  e.g. cd ../callgrapherbuild

5. Run configure from the new build directory. NOTE: You must configure the
  project with the same debugging and assertion options as you configured LLVM.
  That is, if you enabled LLVM debugging with
  --disable-optimized --enable-debug-runtime --enable-assertions
  then you should do the same for the project
  e.g. ../callgrapher/configure --with-llvmsrc=<path to llvm src dir> --with-llvmobj=<path to llvm build dir> --disable-optimized --enable-debug-runtime --enable-assertions

  Or for Ubuntu 14.10 in particular:
  ../callgrapher/configure --with-llvmsrc=/usr/lib/llvm-3.5/build/ --with-llvmobj=/usr/lib/llvm-3.5/build/ --disable-optimized --enable-debugging

6. Run make inside the build directory.
  e.g. make

This produces a callgrapher tool in a folder that depends on your
configuration options. If you have assertions and debugging enabled, it will be
Debug+Asserts/bin/callgrapher
If you have assertions enabled and debugging disabled, it will be
Release+Asserts/bin/callgrapher
The library can similarly be found in
Debug+Asserts/lib/ or Release+Asserts/lib/

Running the call graph printer:
e.g.
clang -g -c -emit-llvm ../callgrapher/test/simpletest.c -o calls.bc
Debug+Asserts/bin/callgrapher calls.bc

