Skip to content

Instantly share code, notes, and snippets.

@kwilcox
Created September 10, 2013 19:58
Show Gist options
  • Save kwilcox/6514735 to your computer and use it in GitHub Desktop.
Save kwilcox/6514735 to your computer and use it in GitHub Desktop.
Installing Antlr/zlib/hdf4/hdf5/netcdf4/nco from source
#!/bin/bash
yum install -y gcc gcc-c++ gcc-gfortran curl-devel libxml2-devel bison flex wget make libjpeg-devel expat-devel gsl-devel
INSTALL_PATH=/opt
mkdir -p $INSTALL_PATH/src
# ANTLR2
APP=antlr-2.7.7
ANTLR_PATH=$INSTALL_PATH/$APP
rm -rf $UDUNITS_PATH
cd $INSTALL_PATH/src
rm -rf antlr-*
wget http://www.antlr2.org/download/antlr-2.7.7.tar.gz
tar xzf antlr-2.7.7.tar.gz ; cd antlr-2.7.7
# Bug in antlr-2.7.7
sed -i "13a #include <strings.h>" lib/cpp/antlr/CharScanner.hpp
sed -i "14a #include <cstdio>" lib/cpp/antlr/CharScanner.hpp
CC=gcc CXX='' ./configure \
--prefix=$ANTLR_PATH \
--disable-csharp \
--disable-java \
--disable-python 2>&1 | tee $APP.config
make 2>&1 | tee $APP.make
make install 2>&1 | tee $APP.install
# UDUNITS
APP=udunits-2.1.24
UDUNITS_PATH=$INSTALL_PATH/$APP
rm -rf $UDUNITS_PATH
cd $INSTALL_PATH/src
rm -rf udunits-*
wget ftp://ftp.unidata.ucar.edu/pub/udunits/udunits-2.1.24.tar.gz
tar xzf udunits-2.1.24.tar.gz ; cd udunits-2.1.24
CC=gcc CXX='' F77=gfortran ./configure \
--prefix=$UDUNITS_PATH 2>&1 | tee $APP.config
make 2>&1 | tee $APP.make
make install 2>&1 | tee $APP.install
# ZLIB
APP=zlib-1.2.7
ZLIB_PATH=$INSTALL_PATH/$APP
rm -rf $ZLIB_PATH
cd $INSTALL_PATH/src
rm -rf zlib-*
wget http://zlib.net/zlib-1.2.8.tar.gz
tar zxf zlib-1.2.8.tar.gz ; cd zlib-1.2.8
CC=gcc FC=gfortran CXX='' ./configure \
--prefix=$ZLIB_PATH | tee $APP.config
make 2>&1 | tee $APP.make
make install 2>&1 | tee $APP.install
# HDF4
APP=hdf-4.2.9
HDF4_PATH=$INSTALL_PATH/$APP
rm -rf $HDF4_PATH
cd $INSTALL_PATH/src
rm -rf hdf-4*
wget http://www.hdfgroup.org/ftp/HDF/releases/HDF4.2.9/src/hdf-4.2.9.tar.gz
tar xzf hdf-4.2.9.tar.gz ; cd hdf-4.2.9
# Bug in configure script, need to define EGREP variable here
EGREP=egrep CC=gcc FC=gfortran F77=gfortran ./configure \
--prefix=$HDF4_PATH \
--disable-netcdf \
--enable-fortran \
--with-zlib=$ZLIB_PATH \
--with-pic 2>&1 | tee $APP.config
make 2>&1 | tee $APP.make
make install 2>&1 | tee $APP.install
# HDF5
APP=hdf5-1.8.11
HDF5_PATH=$INSTALL_PATH/$APP
rm -rf $HDF5_PATH
cd $INSTALL_PATH/src
rm -rf hdf5-*
wget http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8.11/src/hdf5-1.8.11.tar.gz
tar xzf hdf5-1.8.11.tar.gz ; cd hdf5-1.8.11
CC=gcc FC=gfortran CXX='' ./configure \
--prefix=$HDF5_PATH \
--enable-fortran \
--with-zlib=$ZLIB_PATH \
--with-pic 2>&1 | tee $APP.config
make 2>&1 | tee $APP.make
make install 2>&1 | tee $APP.install
export LD_LIBRARY_PATH=$HDF4_PATH/lib:$LD_LIBRARY_PATH
export PATH=$HDF4_PATH/bin:$PATH
export LD_LIBRARY_PATH=$HDF5_PATH/lib:$LD_LIBRARY_PATH
export PATH=$HDF5_PATH/bin:$PATH
export LD_LIBRARY_PATH=$ANTLR_PATH/lib:$LD_LIBRARY_PATH
export PATH=$ANTLR_PATH/bin:$PATH
export LD_LIBRARY_PATH=$UDUNITS_PATH/lib:$LD_LIBRARY_PATH
export PATH=$UDUNITS_PATH/bin:$PATH
export LD_LIBRARY_PATH=$ZLIB_PATH/lib:$LD_LIBRARY_PATH
export PATH=$ZLIB_PATH/bin:$PATH
# NetCDF4
APP=netcdf-4.3.0
NETCDF4_PATH=$INSTALL_PATH/$APP
rm -rf $NETCDF4_PATH
cd $INSTALL_PATH/src
rm -rf netcdf-4*
wget http://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-4.3.0.tar.gz
tar xzf netcdf-4.3.0.tar.gz ; cd netcdf-4.3.0
CPPFLAGS="-I$HDF5_PATH/include -I$ZLIB_PATH/include -I$HDF4_PATH/include -I$ANTLR_PATH/include" \
LDFLAGS="-L$HDF5_PATH/lib -L$ZLIB_PATH/lib -L$HDF4_PATH/lib -L$ANTLR_PATH/lib" \
LIBS="-lmfhdf -lhdf5_hl -lhdf5 -lantlr -ldf -ljpeg -lz" \
CC=gcc ./configure \
--prefix=$NETCDF4_PATH \
--enable-static \
--enable-shared \
--enable-netcdf4 \
--enable-hdf4 \
--with-pic 2>&1 | tee $APP.config
make 2>&1 | tee $APP.make
make install 2>&1 | tee $APP.install
export LD_LIBRARY_PATH=$NETCDF4_PATH/lib:$LD_LIBRARY_PATH
export PATH=$NETCDF4_PATH/bin:$PATH
# NCO
APP=nco-4.3.2
NCO_PATH=$INSTALL_PATH/$APP
rm -rf $NCO_PATH
cd $INSTALL_PATH/src
rm -rf nco-*
wget http://nco.sourceforge.net/src/nco-4.3.2.tar.gz
tar xzf nco-4.3.2.tar.gz ; cd nco-4.3.2
#LIBS="-lmfhdf -lhdf5_hl -lhdf5 -lantlr -ldf -ljpeg -lz -ludunits2" \
CC=gcc CXX='' \
NETCDF_INC=$NETCDF4_PATH/include \
NETCDF_LIB=$NETCDF4_PATH/lib \
NETCDF4_ROOT=$NETCDF4_PATH \
HDF5_LIB_DIR=$HDF5_PATH/lib \
UDUNITS2_PATH=$UDUNITS_PATH \
LDFLAGS="-L$ZLIB_PATH/lib -L$NETCDF4_PATH/lib -L$HDF5_PATH/lib -L$HDF4_PATH/lib -L$ANTLR_PATH/lib -L$UDUNITS_PATH/lib" \
CPPFLAGS="-I$ZLIB_PATH/include -I$NETCDF4_PATH/include -I$HDF5_PATH/include -I$HDF4_PATH/include -I$ANTLR_PATH/include -I$UDUNITS_PATH/include" \
./configure \
--prefix=$NCO_PATH \
--disable-shared \
--enable-udunits2 \
--enable-netcdf-4 2>&1 | tee $APP.config
make 2>&1 | tee $APP.make
make install 2>&1 | tee $APP.install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment