set -e THIRDPARTYINCLUDE=~/thirdparty/include/ THIRDPARTYLIB=~/thirdparty/lib/ BASEDIR=`pwd` INSTALLDIR=~/localinstall PYENV="" MANYLINUXBUILD='no' DEBUG='no' CLEAN='no' echo " " echo " " echo "***********************************************************************************************************" echo "* SasktranCoreComponents port to Linux, 2016-11-03" echo "* ------------------------------------------------" echo "* This script is used to built the USASK-ARG SasktranCoreComponents taken from the master branch" echo "* of the SasktranCoreComponents repository at git@arggit.usask.ca:ARGPackages/SasktranCoreComponents.git" echo "* Note:" echo "* This repository contains submodules that must be initialized and updated with" echo "* > git submodule init" echo "* and > git submodule update" echo "* " echo "* " while getopts "b:i:l:p:mchg" opt; do case $opt in m) MANYLINUXBUILD="yes" ;; b) INSTALLDIR=$OPTARG ;; i) THIRDPARTYINCLUDE=$OPTARG ;; p) PYENV=$OPTARG ;; l) THIRDPARTYLIB=$OPTARG ;; c) CLEAN="yes" ;; g) DEBUG="yes" ;; h) echo "* buildarglibrarieslinux -b -i -p -g -c -h" echo "* " echo "* Options:" echo "* -b : Install libraries, executables, caches registry under this folder" echo "* default is ~/localinstall" echo "* -i : Directories used to search for header files of third party software, colon separated list, default is ~/thirdparty/include/" echo "* -l : Directories used to search for third party libraries, colon separated list, default is ~/thirdparty/lib/" echo "* -p : Build the wheel using the specified python environment" echo "* (uses 'source activate ' and 'source deactivate'), default uses current python environment" echo "* -m : Build the manylinux python wheel. You must be in a suitable Docker environment and have , default no" echo "* -c : clean the projects as they are built. Default is not to clean." echo "* -g : Build debug versions. Note that you should also use option -c to ensure" echo "* all objects are rebuilt in debug mode" echo "* -h : print this message and exit" echo "* " echo "***********************************************************************************************************" exit ;; \?) echo "Invalid option: -$OPTARG" >&2 exit ;; esac done shift "$((OPTIND-1))" # Shift off the options and optional --. SASKTRANIF_VERSION_WITHSPACE=$(sed -n '//{s:[:space:]*\([-0-9\.a-zA-Z_+]*\)[:space:]*:\1: p}' ./Repos_SasktranV3/sasktranif_version.props) SASKTRANIF_VERSION="$(echo -e "${SASKTRANIF_VERSION_WITHSPACE}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" export SASKTRANIF_VERSION if [ -z "$PYENV" ] then PYENVOSTR="Current Environment" else PYENVOSTR="$PYENV" fi echo "* Options Used for Build" echo "* ----------------------" echo "* Installation Directory = $INSTALLDIR" echo "* Third Party Includes = $THIRDPARTYINCLUDE" echo "* Third Party libraries = $THIRDPARTYLIB" echo "* CLEAN projects = $CLEAN" echo "* DEBUG code = $DEBUG" echo "* SASKTRANIF Version = $SASKTRANIF_VERSION" echo "* Python Environment = $PYENVOSTR" echo "***********************************************************************************************************" echo " " CPLUS_INCLUDE_PATH=$BASEDIR/Repos_BaseCode/nxbase:$CPLUS_INCLUDE_PATH CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$BASEDIR/Repos_BaseCode/lapack CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$BASEDIR/Repos_BaseCode/atombase CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$BASEDIR/Repos_SasktranIF CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$BASEDIR/Repos_skclimatology:$BASEDIR/Repos_skopticalproperties CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$BASEDIR/Repos_BaseCode/nxhdf/nxnetcdfio:$BASEDIR/Repos_BaseCode/nxhdf/nxhdfeos:$BASEDIR/Repos_BaseCode/nxhdf/nxhdfeos5 CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:$THIRDPARTYINCLUDE CORE_INCLUDE=$CPLUS_INCLUDE_PATH LIBRARY_PATH=$THIRDPARTYLIB:$LIBRARY_PATH LD_RUN_PATH=$THIRDPARTYLIB:$LD_RUN_PATH export CPLUS_INCLUDE_PATH LIBRARY_PATH LD_RUN_PATH pushd Repos_BaseCode #autoconf configure.in > configure #chmod u+x configure ./configure --prefix=$INSTALLDIR --enable-debug=$DEBUG if [ $CLEAN == "yes" ]; then make clean; fi make make install popd pushd Repos_SasktranIF #autoconf configure.in > configure #chmod u+x configure ./configure --prefix=$INSTALLDIR --enable-debug=$DEBUG if [ $CLEAN == "yes" ]; then make clean; fi make make install popd pushd Repos_skclimatology #autoconf configure.in > configure #chmod u+x configure ./configure --prefix=$INSTALLDIR --enable-debug=$DEBUG if [ $CLEAN == "yes" ]; then make clean; fi make make install popd pushd Repos_skopticalproperties #autoconf configure.in > configure #chmod u+x configure ./configure --prefix=$INSTALLDIR --enable-debug=$DEBUG if [ $CLEAN == "yes" ]; then make clean; fi make make install popd pushd Repos_SasktranV3 #autoconf configure.in > configure #chmod u+x configure ./configure --prefix=$INSTALLDIR --enable-debug=$DEBUG SASKTRANIF_VERSION=$SASKTRANIF_VERSION if [ $CLEAN == "yes" ]; then make clean; fi make make install popd if [ -n "$PYENV" ] then echo "Activating python environment $PYENV" source activate $PYENV fi pushd SasktranCoreComponents_Installers #autoconf configure.in > configure #chmod u+x configure ./configure --prefix=$INSTALLDIR --enable-debug=$DEBUG SASKTRANIF_VERSION=$SASKTRANIF_VERSION if [ $CLEAN == "yes" ]; then make -f makefile.sasktrancorecomponents clean; fi make -f makefile.sasktrancorecomponents make -f makefile.sasktrancorecomponents install popd PYVER=`python -c "import sys;print(sys.version_info.major*10+sys.version_info.minor)"` THISDIR=`pwd` cd $INSTALLDIR/pythonwheel WHEELNAME=`ls sasktranif-$SASKTRANIF_VERSION-cp$PYVER*-linux_*.whl` cd $THIS if [ -n "$PYENV" ] then echo "Deactivating python environment $PYENV" source deactivate fi if [ "$MANYLINUXBUILD" = "yes" ]; then echo "Making the manylinux python wheel" THISDIR=`pwd` cd $INSTALLDIR/pythonwheel auditwheel repair -L purelib/sasktranif/.libs $WHEELNAME cp ./wheelhouse/*.whl ./ WHEELNAME=`ls sasktranif-$SASKTRANIF_VERSION-cp$PYVER*-manylinux*.whl` cd $THISDIR fi echo " " echo "__ ___ _ _ _ " echo "\ \ / / |__ ___ ___ | | | | ___ ___ | | " echo " \ \ /\ / /| '_ \ / _ \ / _ \ | |_| |/ _ \ / _ \| | " echo " \ V V / | | | | (_) | (_) | | _ | (_) | (_) |_| " echo " \_/\_/ |_| |_|\___/ \___/ |_| |_|\___/ \___/(_) " echo " " echo " _____ _ ____ _ _ " echo "|_ _| |__ ___ | _ \ _ _| |_| |__ ___ _ __ " echo " | | | '_ \ / _ \ | |_) | | | | __| '_ \ / _ \| '_ \ " echo " | | | | | | __/ | __/| |_| | |_| | | | (_) | | | | " echo " |_| |_| |_|\___| |_| \__, |\__|_| |_|\___/|_| |_| " echo " |___/ " echo "__ ___ _ ___ ____ _ _ _ " echo "\ \ / / |__ ___ ___| | |_ _|___ | __ ) _ _(_) | |_ " echo " \ \ /\ / /| '_ \ / _ \/ _ \ | | |/ __| | _ \| | | | | | __| " echo " \ V V / | | | | __/ __/ | | |\__ \ | |_) | |_| | | | |_ " echo " \_/\_/ |_| |_|\___|\___|_| |___|___/ |____/ \__,_|_|_|\__| " echo " " echo " -------------------------------------------------------------- " echo " ____ _ _ _ " echo "| _ \ ___ __ _ __| | | |_| |__ ___ " echo "| |_) / _ \/ _ |/ _ | | __| '_ \ / _ \ " echo "| _ < __/ (_| | (_| | | |_| | | | __/ " echo "|_| \_\___|\__,_|\__,_| \__|_| |_|\___| " echo " " echo " _ _ _ _ " echo "(_)_ __ ___| |_ _ __ _ _ ___| |_(_) ___ _ __ ___ " echo "| | '_ \/ __| __| '__| | | |/ __| __| |/ _ \| '_ \/ __| " echo "| | | | \__ \ |_| | | |_| | (__| |_| | (_) | | | \__ \ " echo "|_|_| |_|___/\__|_| \__,_|\___|\__|_|\___/|_| |_|___/ " echo " " echo " _ _ _ " echo "| |__ ___| | _____ _| | " echo "| '_ \ / _ \ |/ _ \ \ /\ / / | " echo "| |_) | __/ | (_) \ V V /|_| " echo "|_.__/ \___|_|\___/ \_/\_/ (_) " echo " " echo " ---------------------------------------------------------------------------" echo " " echo " Here is a recap of the Options Used for the build" echo " ---------------------------------------------" echo " Python Wheel at = $INSTALLDIR/pythonwheel/$WHEELNAME" echo " Third Party Includes = $THIRDPARTYINCLUDE" echo " Third Party libraries = $THIRDPARTYLIB" echo " CLEAN projects = $CLEAN" echo " DEBUG code = $DEBUG" echo " SASKTRANIF Version = $SASKTRANIF_VERSION" echo " Python Environment = $PYENVOSTR" echo " Python ManyLinux Build = $MANYLINUXBUILD" echo " " echo "FYI: " echo " 1. The python wheel for SasktranIF, Version $SASKTRANIF_VERSION has been built." echo " 2. The wheel is at $INSTALLDIR/pythonwheel/$WHEELNAME" echo " 2. The wheel was built using $PYENVOSTR" echo " 3. The wheel can be installed into any compatible python environment." echo " " echo " Wheel Installation Details:" echo " ---------------------------" echo " You must manually install the wheel into any python environment of your choice," echo " as long as it is compatible with $PYENVOSTR. It is a 2 step process:" echo " " echo " 1. pip install --upgrade $WHEELNAME" echo " " echo " 2. start python interpreter and initialize the core component registry settings" echo " python" echo " >>> import sasktranif" echo " >>> " echo " " echo "------------------------------------------------------------------------------" echo " "