Build script for R / HDF5 on Solaris 10 x64 32bit

Rather than following my long howto, I’ve written a script to automate much of the work. You still need to follow the manual hand edits stated in step 5 of the howto. For debug build, follow the instructions stated in this howto. Below are the environment variable file and build script file that I used to make a debug build of R / HDF5. You should change environment variables in bash.profile to fit your environment. This script assumes the following directory structure:

./bash.profile
./makeall.sh
./src/[R_SRC]
./src/[NCSA_HDF5_SRC]
./src/[R_HDF5_SRC]
./src/[SZIP_SRC]

NOTE: This script is provides AS-IS without any guarantee. Although the author tested this script in his own environment, it may or may not work in all environments. Since the source is provided, the author expect you to carefully exam the code prior to execution, which will enable you to become aware of potential risks. By running this script, you agree not to hold the author liable for anything that may happen as result of running this script.

bash.profile

export LANG=en_US
export LC_ALL=en_US
export LC_MESSAGES=en_US
export BASE_DIR=/export
export STUDIO_DIR=/opt/studio11/SUNWspro
export R_VER=R-2.5.0
export HDF5_VER=hdf5-1.6.5
export SZIP_VER=szip-2.0
export CC="${STUDIO_DIR}/bin/cc -g"
export CXX="${STUDIO_DIR}/bin/CC -g"
export F77="${STUDIO_DIR}/bin/f77 -g"
export CFLAGS="-xtarget=opteron -I${BASE_DIR}/build/hdf5-1.6.5/include -DH5_USING_PURIFY"
export CXXFLAGS="-xtarget=opteron"
export FFLAGS="-xtarget=opteron"
export FCFLAGS="-xtarget=opteron"
export LDFLAGS="-xtarget=opteron -L/usr/lib -L/opt/csw/lib"
export PATH=${STUDIO_DIR}/bin:/usr/ccs/bin:/usr/dt/bin:/usr/xpg4/bin:/usr/bin:/opt/csw/bin:/usr/sfw/bin
export R_HOME=${BASE_DIR}/build/${R_VER}
export HDF5_HOME=${BASE_DIR}/build/${HDF5_VER}
export SZIP_HOME=${BASE_DIR}/build/${SZIP_VER}
export LD_LIBRARY_PATH=/opt/csw/lib:/usr/lib:/usr/local/lib:/usr/sfw/lib:${R_HOME}/lib:${HDF5_HOME}/lib:${SZIP_HOME}/lib

makeall.sh

#!/usr/bin/bash --debug

# Initialize env variables
source ./bash.profile
DEBUG=0
POINTER="buildszip"

# Set debug mode to 1 or 0
# Debug mode will cause the script to pause after each make intall
# to enable the user to double check if each modeule was built correctly
# Souce: http://tldp.org/LDP/abs/html/testbranch.html#ISALPHA
while [ $# -gt 0 ]; do    # Until you run out of parameters . . .
  case "$1" in
    -d|--debug)
              # "-d" or "--debug" parameter?
              DEBUG=1
              ;;
# Reserved for future use
#    -c|--conf)
#              CONFFILE="$2"
#              shift
#              if [ ! -f $CONFFILE ]; then
#                echo "Error: Supplied file doesn't exist!"
#                exit $E_CONFFILE     # File not found error.
#              fi
#              ;;
  esac
  shift       # Check next set of parameters.
done

tocontinueornot()
{
  if [ ${DEBUG} = 1 ]; then
    echo "So far so good? [y/n/r]"
    read TOCONTINUE
    case "${TOCONTINUE}" in
      "y" | "Y" | "Yes" | "YES" | "yes" )
        echo "Continue to the next step."
        ;;
      "n" | "N" | "No" | "NO" | "no" )
        echo "Exiting."
        exit 0
        ;;
      "r" | "R" | "retry" | "Retry" | "RETRY" )
        echo "Attempting to rerun for this module."
        case "$POINTER" in
          "buildszip" ) buildszip;;
          "buildncsahdf5" ) buildncsahdf5;;
          "configurerhdf5" ) configurerhdf5;;
          "buildr" ) buildr;;
          "installrhdf5" ) installrhdf5;;
        esac
        ;;
      esac
  fi
}

buildszip()
{
  echo "=============================================================="
  echo "Building SZip"
  echo "=============================================================="
  cd ${BASE_DIR}/src/${SZIP_VER}
  make clean
  ./configure --prefix=${SZIP_HOME}
  make
  make check
  make install
  POINTER="buildszip"
  tocontinueornot
}

buildncsahdf5()
{
  echo "=============================================================="
  echo "Building NCSA HDF5 Library"
  echo "=============================================================="
  cd ${BASE_DIR}/src/${HDF5_VER}
  make clean
  #./configure --disable-shared --enable-debug --disable-production --with-zlib=/usr --with-szlib=${SZIP_HOME}  --prefix=${HDF5_HOME} --enable-cxx
  ./configure --enable-debug --disable-production --with-zlib=/usr --with-szlib=${SZIP_HOME}  --prefix=${HDF5_HOME} --enable-cxx
  make
  make check
  make install
  POINTER="buildncsahdf5"
  tocontinueornot
}

configurerhdf5()
{
  echo "=============================================================="
  echo "Configure R HDF5"
  echo "Note: This script assumes you already tweaked the configure"
  echo "script according to the instructions poted at"
  echo "https://vegdave.wordpress.com/2006/12/02/builld-project-r-with-hdf5-on-solaris-10-x64-in-32bit/"
  echo "=============================================================="
  cd ${BASE_DIR}/src/hdf5
  ./configure --with-hdf5=${HDF5_HOME}  --with-zlib=/usr
  echo "Output the last line of config.log. Note: you should see exit 0"
  tail -1 config.log
  POINTER="configurerhdf5"
  tocontinueornot
}

buildr()
{
  echo "=============================================================="
  echo "Build R"
  echo "=============================================================="
  cd ${BASE_DIR}/src/${R_VER}
  make clean
  ./configure --prefix=${R_HOME} --with-x=no
  make
  make check
  make install
  POINTER="buildr"
  tocontinueornot
}

installrhdf5()
{
  cd ${R_HOME}/lib/R/bin
  ./R CMD INSTALL ${BASE_DIR}/src/hdf5
  POINTER="installrhdf5"
  tocontinueornot
}

# call each function to build/configure each module
buildszip
buildncsahdf5
configurerhdf5
buildr
installrhdf5
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s