How to build and install GRIB API library/tools
================================================

Building and installation has been tested on several platforms and with several compilers.
However for some platforms modifications to the installation engine may be required.
If you encounter any problems during the installation procedure please send an e-mail
with your problem to:

    Software.Support@ecmwf.int


Installation using CMake
------------------------
This is the recommended method of installation.
However it requires that cmake be installed on your system.

1. Download GRIB API from https://software.ecmwf.int/wiki/display/GRIB/Releases

2. Unpack distribution:
   > tar -xzf grib_api-x.y.z-Source.tar.gz

3. Create a separate directory for the build:
   > mkdir build
   > cd build

4. Run cmake pointing to the source and specify the installation location
   > cmake  ../grib_api-x.y.z-Source -DCMAKE_INSTALL_PREFIX=/path/to/where/you/install/gribapi

5. Compile, test and install:
   > make
   > ctest
   > make install

You can also pass options to the cmake command above. Some typical examples are:

 -DBUILD_SHARED_LIBS=OFF         Install static libraries, not shared
 -DENABLE_JPG=ON                 Enable JPEG encoding/decoding
 -DCMAKE_Fortran_COMPILER=pgf90  Set Fortran compiler to Portland Group F90 compiler
 -DCMAKE_C_FLAGS="-O2 -Wall"     Prepend the specified flags at the front
                                 of the compilation command for C source files

For more details, please see:
https://software.ecmwf.int/wiki/display/GRIB/GRIB+API+CMake+installation


Installation using Autotools
----------------------------
GRIB API also supports installation via the "configure" script (Autotools).
However this feature is deprecated and may not be supported in the future.
We would recommend all users to switch to CMake.

1. Download GRIB API from https://software.ecmwf.int/wiki/display/GRIB/Releases

2. Unpack distribution:
   > tar -xzf grib_api-x.y.z-Source.tar.gz

3. Run the configure script in the directory created:
   > cd grib_api-x.y.z-Source
   > ./configure --prefix=/path/to/where/you/install/gribapi

5. make, check and install:

   > make
   > make check
   > make install

For more details, please see:
https://software.ecmwf.int/wiki/display/GRIB/GRIB+API+Autotools+installation
