<?xml version="1.0" encoding="utf-8"?>
<section version="5.0"
         xsi:schemaLocation="http://docbook.org/ns/docbook http://docbook.org/xml/5.0/xsd/docbook.xsd"
         xml:id="development.build_linux" xmlns="http://docbook.org/ns/docbook"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:xs="http://www.w3.org/2001/XMLSchema"
         xmlns:xlink="http://www.w3.org/1999/xlink"
         xmlns:xi="http://www.w3.org/2001/XInclude"
         xmlns:ns="http://docbook.org/ns/docbook">
  <title>Building OVITO on Linux</title>

  <para>
  Note that the following instructions have been written for Ubuntu Linux 14.04 or later, or any compatible Debian-based distribution.
  Other Linux distributions may require slightly modified steps. 
  </para>
  
 <simplesect>
    <title>Installing dependencies</title>
    <para>
    First install the required <link linkend="development.requirements">build tools and third-party libraries</link>
    by running
<screen><command>sudo apt-get install build-essential git cmake-curses-gui qt5-default libboost-dev libqt5scintilla2-dev \
                     libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavresample-dev \
                     libavutil-dev libswscale-dev libnetcdf-dev libhdf5-dev libhdf5-serial-dev \
                     libbotan1.10-dev libmuparser-dev python3-dev \
                     python3-sphinx python3-numpy python3-sip python3-pyqt5 \
                     xsltproc docbook-xml doxygen
</command></screen>
  </para>
  </simplesect>

 <simplesect>
    <title>Downloading the source code</title>
    <para>
    Then download OVITO's source code into a new subdirectory named <filename>ovito/</filename>: 
<screen><command>git clone https://gitlab.com/stuko/ovito.git ovito</command></screen>
  </para>
  </simplesect>

  <simplesect>
    <title>Compiling OVITO</title>
    <para>
    Within that directory, create a build directory and let <link xlink:href="http://www.cmake.org/">CMake</link> generate the Makefile: 
<screen>
<command>cd ovito
mkdir build
cd build
cmake -DOVITO_BUILD_DOCUMENTATION=ON \
      -DCMAKE_BUILD_TYPE=Release \
      -DPYTHON_INCLUDE_DIR=/usr/include/python3.5m \
      -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so \
      ..
</command></screen>
  </para>
  <para>
    If this step fails, or if you want to disable certain components of OVITO, you can now run "<command>ccmake .</command>" to open the 
    <link xlink:href="http://www.cmake.org/">CMake</link> configuration program.
    Changin the <literal>PYTHON_INCLUDE_DIR</literal> and <literal>PYTHON_LIBRARY</literal> settings may be needed to 
    build OVITO against a different Python version. 
  </para>
  <para>
    Finally, compile OVITO: 
<screen>
<command>make -j4</command></screen>
After a successful build, the executable can be found in the <filename>ovito/build/bin</filename> directory.
  </para>
  </simplesect>
  
</section>
