docs/building: add doxygen information
[contrib/mraa.git] / docs / building.md
1 Building libmraa                         {#building}
2 ===============
3
4 libmraa uses cmake in order to make compilation relatively painless. Cmake runs
5 build out of tree so the recommended way is to clone from git and make a build/
6 directory inside the clone directory.
7
8 ## Build dependencies
9 Not all these are required but if you're unsure of what you're doing this is
10 what you'll need:
11 * [SWIG](http://swig.org) 3.0.5+
12 * [git](http://git-scm.com)
13 * [python](http://python.org) 2.7 or 3.4+ (you'll need not just the interpreter but python-dev)
14 * [node.js](http://nodejs.org) 0.10.x (you'll need not just the interpreter but nodejs-dev)
15 * [CMake](http://cmake.org) 2.8.8+
16 * [Doxygen](http://www.stack.nl/~dimitri/doxygen/) 1.8.9.1+
17 * [Sphinx](http://sphinx-doc.org/) 1.1.3+ (For Python docs)
18
19 ## Basic build steps
20
21 ~~~~~~~~~~~~~{.sh}
22 mkdir build
23 cd build
24 cmake ..
25 make
26 ~~~~~~~~~~~~~
27
28 If this goes wrong and you have all the dependencies installed, then please
29 file an issue with the full output of `cmake ..` and `make` or however far you
30 got.
31
32 ## Configuration flags
33
34 Our cmake configure has a number of options, cmake-gui or ccmake (cmake -i is
35 no longer with us :() can show you all the options. A few of the more common
36 ones are listed below. Note that when the option starts with CMAKE_ it's an
37 option that is made available by cmake and will be similar in all cmake
38 projects. You need to add them after `cmake` but before `..`.
39
40 A few recommended options:
41 Changing install path from /usr/local to /usr:
42  -DCMAKE_INSTALL_PREFIX:PATH=/usr
43
44 Building debug build - adds -g and disables optimisations - this will force a
45 full rebuild:
46  -DCMAKE_BUILD_TYPE=DEBUG
47
48 Using clang instead of gcc:
49  -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++
50
51 Building with an older version of SWIG (< 3.0.2) requires the disabling of javascript:
52  -DBUILDSWIGNODE=OFF
53
54 Disabling python module building:
55  -DBUILDSWIGPYTHON=OFF
56
57 Building doc, this will require [SPHINX](http://sphinx-doc.org) &
58 [Doxygen](http://doxygen.org):
59  -BUILDDOC=ON
60
61 ## Dependencies continued
62
63 You'll need at least SWIG version 3.0.2 and we recommend 3.0.5 to build the
64 javascript & python modules. If your version of SWIG is older than this then
65 please see above for disabling SWIGNODE. Otherwise you will get a weird build
66 failure when building the javascript module. The python module builds with SWIG
67 2.x.
68
69 During the build, we'll assume you're building from git, note that if you
70 compile with git installed your version of mraa will be tagged -dirty. This
71 simply means git wasn't installed or that you where building form a tarball.
72 You can modify build/src/version.c before running make if this is incorrect.
73 The instructions listed here all assume that build/ is an empty dir that lives
74 inside the cloned repository of mraa.
75
76 If you have multiple versions of python then mraa can get confused, we
77 recommend using virtualenv to select which version of python you want. We test
78 2.7 the most but SWIG will generate valid 3.x python code but we do not
79 generally support building both at once.
80
81 ## Using a yocto/oe toolchain
82
83 In order to compile with a yocto/oe toolchain use the following toolchain file.
84 This works well on the edison 1.6 SDK. First source the environment file, then
85 use our cmake toolchain file.
86
87 ~~~~~~~~~~~~~{.sh}
88 source /opt/poky-edison/1.6/environment-setup-core2-32-poky-linux
89 mkdir build
90 cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchains/oe-sdk_cross.cmake ..
91 make
92 ~~~~~~~~~~~~~
93
94 ## Using coverity
95
96 Static analysis is routinely performed using coverity on libmraa's codebase.
97 This is the procedure to submit a build to coverity. You'll need to install
98 coverity-submit for your OS.
99
100 ~~~~~~~~~~~~~{.sh}
101 mkdir covbuild/ && cd covbuild
102 cmake -DBUILDDOC=OFF -DBUILDSWIG=OFF ..
103 cov-build --dir cov-int make
104 tar caf mraa.tar.bz2 cov-int
105 ~~~~~~~~~~~~~