#!/bin/bash # Copyright (c) 2014, Joseph Hunkeler # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if [ ! -z "${UR_DIR}" ]; then echo "UREKA must not be active." exit 1 fi export build_temp=/tmp/ur_optimize_build function init_optimize { if [ -d "${PREFIX}" ]; then echo "${PREFIX} exists. Abort." exit 1 fi mkdir -p ${PREFIX} if (( $? > 0 )); then exit $? fi if [ -d "${build_temp}" ]; then deinit_optimize fi mkdir -p "${build_temp}" cd "${build_temp}" } function deinit_optimize { rm -rf "${build_temp}" } function stage_ATLAS { local url="http://sourceforge.net/projects/math-atlas/files/Stable/3.10.2/atlas3.10.2.tar.bz2" local tarball="$(basename ${url})" wget "${url}" tar xf "${tarball}" } function stage_LAPACK { local url="http://www.netlib.org/lapack/lapack-3.5.0.tgz" local tarball="$(basename ${url})" wget "${url}" #tar xf "${tarball}" } function build_ATLAS { local BUILDROOT=`pwd` stage_ATLAS stage_LAPACK cd ATLAS mkdir -p BUILD && cd BUILD ../configure --prefix=${PREFIX} \ --with-netlib-lapack-tarfile=${BUILDROOT}/lapack-3.5.0.tgz \ --shared \ -b 64 \ -Fa alg "-fPIC -Wl,-rpath=${PREFIX}/lib,--enable-new-dtags" \ -Si latune 1 make make shared make ptshared make install return $? } function build_modules { export ATLAS="${PREFIX}" export BLAS="${PREFIX}" export LAPACK="${PREFIX}" local packages=( numpy scipy ) for package in "${packages[@]}" do yes | pip uninstall ${package} done for package in "${packages[@]}" do yes | pip install --upgrade --force ${package} done return $? } NO_ARGS=0 E_OPTERROR=85 if [ $# -eq "$NO_ARGS" ]; then echo "Usage: `basename $0` -p {ureka_installation_path}" exit $E_OPTERROR fi while getopts ":p:" opt do case $opt in p) export UREKA=${OPTARG} ;; :) echo "-$OPTARG requires an argument (e.g. path to UREKA installation)" ;; esac done shift $(($OPTIND - 1)) # Begin main script set -x export PREFIX="${UREKA}/ext" init_optimize build_ATLAS if (( $? > 0 )); then echo "ATLAS build failed. Abort." exit 1 fi # Initialize UREKA for building modules eval `${UREKA}/bin/ur-setup-real -sh` # Configure build environment variables to avoid UREKA entirely # - ABSOLUTELY REQUIRED - export F77="gfortran" export F2C="" export CC="/usr/bin/gcc" export CXX="/usr/bin/g++" export CPP=${CXX} build_modules if (( $? > 0 )); then echo "Python module builds failed. Abort." exit 1 fi deinit_optimize