**************************************************************************
Note: This file contains instructions how to build the statically linked 
version of OVITO on a Ubuntu 10.04 Linux system. 
This procedure is used to create the official distribution on the website. 

Building a dynamically linked executable on a local system is simpler 
and is described in OVITO's user manual.
**************************************************************************

**************************************************************************
Install essential tools and dependencies on Ubuntu 10.04 for 
building the static executable:
**************************************************************************

sudo apt-get install \
   libfreetype6-dev \
   libfontconfig-dev \
   libx11-xcb-dev \
   libpcre3-dev \
   libxi-dev \
   libsm-dev \
   libice-dev \
   libglu1-mesa-dev \
   libxrender-dev \
   xsltproc \
   docbook-xml \
   libssl-dev \
   liblapack3gf \
   ncurses-dev \
   libssl-dev \
   libreadline-dev \
   povray \
   libfftw3-dev

**************************************************************************
Install GNU g++ 5 compiler on Ubuntu 10.04
**************************************************************************

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5 g++-5
sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 20
sudo update-alternatives --config gcc
sudo update-alternatives --config g++

**************************************************************************
Build Qt libraries (version 5.7):
**************************************************************************

./configure \
	-opensource \
	-confirm-license \
	-shared \
	-no-qml-debug \
	-nomake examples \
	-qt-libpng \
	-qt-libjpeg \
	-qt-pcre \
	-qt-xcb \
	-qt-xkbcommon-x11 \
	-no-nis \
	-no-cups \
	-no-glib \
	-no-xinput2 \
	-no-alsa \
	-no-pulseaudio \
	-pch \
	-no-eglfs \
	-no-linuxfb \
	-skip qtconnectivity \
	-skip qtmultimedia \
	-skip qt3d \
	-skip qtcanvas3d \
	-skip qtcharts \
	-skip qtxmlpatterns \
	-skip qtlocation \
	-skip qtsensors \
	-skip qtdeclarative \
	-skip qtdoc \
	-skip qtquickcontrols \
	-skip qtquickcontrols2 \
	-skip qtserialport \
	-skip qtgraphicaleffects \
	-skip qttranslations \
	-skip qtwebchannel \
	-skip qtactiveqt \
	-skip qtdatavis3d \
	-skip qtgamepad \
	-skip qtscript \
	-skip qtserialbus \
	-skip qtvirtualkeyboard \
	-skip qtwayland \
	-skip qtwebengine \
	-skip qtwebsockets \
	-skip qtwebview \
	-prefix $HOME/progs/qt5

make
make install

**************************************************************************
QScintilla2
*************************************************************************
cd QScintilla_gpl-2.9.3/Qt4Qt5/
$HOME/progs/qt5/bin/qmake qscintilla.pro
make

**************************************************************************
Build sqlite3:
**************************************************************************
./configure
make 
sudo make install

**************************************************************************
Build Python (version 3.5.x):
**************************************************************************

Edit Modules/Setup.dist to enable SSL module:

# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c

SSL=/usr
_ssl _ssl.c \
	-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
	-L$(SSL)/lib -lssl -lcrypto

./configure --enable-shared --prefix=$HOME/progs/python
make
make install


**************************************************************************
Install Sphinx:
**************************************************************************
cd $HOME/progs/python/bin
LD_LIBRARY_PATH=$PWD/../lib ./python3 -m pip install sphinx

**************************************************************************
Build NumPy:
**************************************************************************
LD_LIBRARY_PATH=$HOME/progs/python/lib $HOME/progs/python/bin/python3 setup.py install

**************************************************************************
Install IPython:
**************************************************************************
cd $HOME/progs/python/bin
LD_LIBRARY_PATH=$HOME/progs/python/lib ./pip3 install ipython

**************************************************************************
Build SIP:
**************************************************************************
LD_LIBRARY_PATH=$HOME/progs/python/lib $HOME/progs/python/bin/python3 configure.py
make
make install

**************************************************************************
Build PyQt5:
**************************************************************************
LD_LIBRARY_PATH=$HOME/progs/python/lib $HOME/progs/python/bin/python3 configure.py \
   --concatenate \
   --concatenate-split 10 \
   --confirm-license \
   --no-designer-plugin \
   --no-qml-plugin \
   --no-tools \
   --qmake=$HOME/progs/qt5/bin/qmake \
   --sip=$HOME/progs/python/bin/sip \
   --enable QtCore \
   --enable QtGui \
   --enable QtWidgets \
   --enable QtNetwork \
   --enable QtOpenGL \
   --enable QtSvg
make
make install

**************************************************************************
Install matplotlib:
**************************************************************************
cd $HOME/progs/python/bin
LD_LIBRARY_PATH=$HOME/progs/python/lib ./pip3 install matplotlib

**************************************************************************
Build Boost libraries:
**************************************************************************
echo "using python : 3.5 : /home/stuko/progs/python : /home/stuko/progs/python/include/python3.5m ; " > user-config.jam
./bootstrap.sh \
	--with-libraries=system,thread,python \
	--with-python=$HOME/progs/python/bin/python \
	--with-python-root=$HOME/progs/python \
	--with-python-version=3.5 \
	--prefix=$HOME/progs/boost

./b2 --user-config=$PWD/user-config.jam release link=shared install

**************************************************************************
Build libav (release 11):
**************************************************************************
sudo apt-get install yasm
cd libav-11.8
./configure \
	--enable-pic \
	--enable-shared \
	--enable-gpl \
	--disable-static \
	--disable-doc \
	--disable-network \
	--disable-programs \
	--disable-debug \
	--disable-filters \
	--prefix=$HOME/progs/libav

make install

**************************************************************************
Build HDF5:
**************************************************************************
mkdir hdf5_build
cd hdf5_build
$HOME/progs/cmake-3.6.3-Linux-x86_64/bin/cmake \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=../hdf5 \
	-DBUILD_SHARED_LIBS=ON \
	-DHDF5_ENABLE_Z_LIB_SUPPORT=ON \
	-DHDF5_BUILD_HL_LIB=ON \
	../hdf5-1.8.17

make install

**************************************************************************
Build NetCDF:
**************************************************************************
mkdir netcdf_build
cd netcdf_build
$HOME/progs/cmake-3.6.3-Linux-x86_64/bin/cmake \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=../netcdf \
	-DENABLE_DAP=OFF \
	-DENABLE_EXAMPLES=OFF \
	-DENABLE_TESTS=OFF \
	-DBUILD_TESTING=OFF \
	-DBUILD_UTILITIES=OFF \
	-DENABLE_HDF4=OFF \
	-DUSE_HDF5=ON \
	-DHDF5_DIR=$HOME/progs/hdf5/share/cmake \
	-DHDF5_INCLUDE_DIR=$HOME/progs/hdf5/include/ \
	../netcdf-4.4.1/

make install

**************************************************************************
Set the following flags in the CMake configuration to build all features:
**************************************************************************
export LD_LIBRARY_PATH=$HOME/progs/libav/lib:$LD_LIBRARY_PATH
$HOME/progs/cmake-3.6.3-Linux-x86_64/bin/cmake \
  -DOVITO_BUILD_DOCUMENTATION=ON \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=../release_install \
  -DOVITO_REDISTRIBUTABLE_PACKAGE=ON \
  -DBOOST_ROOT=$HOME/progs/boost \
  -DHDF5_DIR=$HOME/progs/hdf5/share/cmake \
  -DnetCDF_DIR=$HOME/progs/netcdf/lib/cmake/netCDF \
  -DPYTHON_EXECUTABLE=$HOME/progs/python/bin/python3 \
  -DPYTHON_LIBRARY=$HOME/progs/python/lib/libpython3.5m.so.1.0 \
  -DPYTHON_INCLUDE_DIR=$HOME/progs/python/include/python3.5m \
  -DSPHINX_PROCESSOR_PATH=$HOME/progs/python/bin \
  -DCMAKE_PREFIX_PATH=$HOME/progs/qt5/ \
  -DQSCINTILLA_INCLUDE_DIR=$HOME/progs/QScintilla_gpl-2.9.3/Qt4Qt5/ \
  -DQSCINTILLA_LIBRARY=$HOME/progs/QScintilla_gpl-2.9.3/Qt4Qt5/libqscintilla2.so.12 \
  -DLIBAV_INCLUDE_DIR=$HOME/progs/libav/include \
  -DLIBAV_LIBRARY_DIR=$HOME/progs/libav/lib \
  ../source/


