An up to date version of this document can be found at following address:

   https://software.ecmwf.int/wiki/display/ODBAPI/ODB+API+Installation


Following software packages are required to build ODB API library and command line tool:

 - cmake 2.8.1 or newer,
 - bison 2.3 or newer,
 - flex (all known versions should be OK),
 - a C++ compiler.

Optionally, to build:

 - ODB API Fortran bindings, a Fortran compiler is required,
 - odb_migrator, a program to convert old ODB databases to the new format, it is required to have a valid installation of the old
   ODB, and a Fortran compiler (the same as the one used to build the old ODB installation),
 - ODB API Python bindings, SWIG 1.3.40 or newer and Python 2.7.

After unpacking ODB API source create a build directory called build/production or build/debug inside the source's
directory. This is where cmake will build binaries - we call it an external build because all the object files and binaries will
be created outside of the source directory. Next step is to call cmake from within the directory (build/production of build/debug).

It is recommended to create a shell script which calls cmake with appropriate options. In case of the example shell session below
this script is called configure_ecmwf_ecgate.sh. 

First parameter passed to cmake in case of an external build must be path to source code directory, in our case: ../.. All other
parameters are optional. Detailed information on available cmake options follows the example.

Cmake creates Makefiles only, so the next step is to call make and actually build the binaries:

  $ pwd
  /tmp/test
  $ tar zxf OdbAPI-0.10.1-dev-Source.tar.gz
  $ cd OdbAPI-0.10.1-dev-Source
  $ mkdir -p build/production
  $ cd build/production
  $ ../../configure_ecmwf_ecgate.sh
  $ make
  $ make install


Cmake options.

In case of an external build the first parameter passed to cmake must be path to source code directory, in our case: ../.. 

Other, optional, cmake options should be passed to cmake with prepended '-D' and followed by '=' and option's value. 
For omitted options cmake will try to find appropriate values. We have included a script configure_example.sh which 
can be used to build ODB API on ECMWF ecgate system.


	CMAKE_C_COMPILER

C compiler.


	CMAKE_CXX_COMPILER

C++ compiler.


	CMAKE_Fortran_COMPILER

Fortran compiler.


	CMAKE_BUILD_TYPE

Build type. Possible values: Debug, Production (case insensitive). At ECMWF we use following snippet to use build directory name
as build type:

  -DCMAKE_BUILD_TYPE=$(basename $(pwd) | sed 's/\W[a-zA-Z0-9]*//')


    CMAKE_INSTALL_PREFIX

Installation directory. The following shell command can be used to set this to a directory with added extra subdirectory with a
name equal to the current version of the software:

  -DCMAKE_INSTALL_PREFIX=/usr/local/apps/odb_api/`cat ../../VERSION.cmake|awk '{print $3}'|sed 's/["]//g'`/


    CMAKE_PREFIX_PATH

A comma separated list of directories where cmake will try to find libraries and tools.


	PGI_PATH

Path to Portland Group Fortran compiler installation.


    ODB_PATH

Path to old ODB installation. Normally it should be set to $ODB_ROOT.


    CMAKE_MODULE_PATH

Path to ECMWF cmake macros. The macros are supplied with ODB API source. For example, if the ODB API source code was unpacked in
directory /tmp/test then CMAKE_MODULE_PATH should be set to /tmp/test/OdbAPI-0.10.1-dev-Source/ecbuild/cmake


    ECKIT_SOURCE

Path to EcKit source. EcKit is supplied with ODB API source. For example, if the ODB API source code was unpacked in directory
/tmp/test then ECKIT_SOURCE should be set to /tmp/test/OdbAPI-0.10.1-dev-Source/eckit


    BUILD_SHARED_LIBS

Possible values: ON or OFF


    ENABLE_MIGRATOR

Spcifies if odb_migrator should be built. Possible values: ON or OFF


    ENABLE_FORTRAN

Specifies if ODB API Fortran interface should be built. Possiblle values: ON or OFF


    ENABLE_PYTHON

Specifies if ODB API Python interface should be built. Possiblle values: ON or OFF


    SWIG_EXECUTABLE

Path to swig executable. This option is only needed if a different swig executable should be needed than the one available on PATH


    XLF_PATH

Path to the IBM's XLF compiler


    BISON_EXECUTABLE

Path to bison executable.


    FLEX_EXECUTABLE

Path to flex executable.

