From 65b9354306d59920460e540e5a6ff488aac1f858 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 28 Dec 2018 11:36:40 +0100 Subject: Replace the detection mess with pkg-config. --- configure.sh | 162 ++--------------------------------------------------------- 1 file changed, 4 insertions(+), 158 deletions(-) diff --git a/configure.sh b/configure.sh index 0182b89..ef7710e 100644 --- a/configure.sh +++ b/configure.sh @@ -9,168 +9,14 @@ if [ "$(echo ${VERBOSE} | tr '[:upper:]' '[:lower:]')" = 'yes' ]; then set -x # Output commands fi set -e # Abort on errors - - - -################################################################################ -# Search -################################################################################ - -if [ -z "${BLAS_DIR}" ]; then - echo "BEGIN MESSAGE" - echo "BLAS selected, but BLAS_DIR not set. Checking some places..." - echo "END MESSAGE" - - FILES="libblas.a libblas.so" - DIRS="/usr/lib /usr/lib64 /usr/local/lib /usr/lib/atlas /usr/lib64/atlas ${HOME}" - for file in $FILES; do - for dir in $DIRS; do - if test -r "$dir/$file"; then - BLAS_DIR="$dir" - break - fi - done - done - - if [ -z "$BLAS_DIR" ]; then - echo "BEGIN MESSAGE" - echo "BLAS not found" - echo "END MESSAGE" - else - echo "BEGIN MESSAGE" - echo "Found BLAS in ${BLAS_DIR}" - echo "END MESSAGE" - fi -fi - - - -################################################################################ -# Build -################################################################################ - -if [ -z "${BLAS_DIR}" \ - -o "$(echo "${BLAS_DIR}" | tr '[a-z]' '[A-Z]')" = 'BUILD' ] -then - echo "BEGIN MESSAGE" - echo "Using bundled BLAS..." - echo "END MESSAGE" - - # Set locations - THORN=BLAS - NAME=blas-3.4.2 - TARNAME=lapack-3.4.2 - SRCDIR=$(dirname $0) - BUILD_DIR=${SCRATCH_BUILD}/build/${THORN} - if [ -z "${BLAS_INSTALL_DIR}" ]; then - INSTALL_DIR=${SCRATCH_BUILD}/external/${THORN} - else - echo "BEGIN MESSAGE" - echo "Installing BLAS into ${BLAS_INSTALL_DIR}" - echo "END MESSAGE" - INSTALL_DIR=${BLAS_INSTALL_DIR} - fi - DONE_FILE=${SCRATCH_BUILD}/done/${THORN} - BLAS_DIR=${INSTALL_DIR} - - if [ "${F77}" = "none" ]; then - echo 'BEGIN ERROR' - echo "Building BLAS requires a Fortran compiler, but there is none configured: F77='${F77}'. Aborting." - echo 'END ERROR' - exit 1 - fi - - if [ -e ${DONE_FILE} -a ${DONE_FILE} -nt ${SRCDIR}/dist/${TARNAME}.tar.gz \ - -a ${DONE_FILE} -nt ${SRCDIR}/configure.sh ] - then - echo "BEGIN MESSAGE" - echo "BLAS has already been built; doing nothing" - echo "END MESSAGE" - else - echo "BEGIN MESSAGE" - echo "Building BLAS" - echo "END MESSAGE" - - # Build in a subshell - ( - exec >&2 # Redirect stdout to stderr - if [ "$(echo ${VERBOSE} | tr '[:upper:]' '[:lower:]')" = 'yes' ]; then - set -x # Output commands - fi - set -e # Abort on errors - cd ${SCRATCH_BUILD} - - # Set up environment - unset LIBS - if [ ${USE_RANLIB} != 'yes' ]; then - RANLIB=': ranlib' - fi - - echo "BLAS: Preparing directory structure..." - mkdir build external done 2> /dev/null || true - rm -rf ${BUILD_DIR} ${INSTALL_DIR} - mkdir ${BUILD_DIR} ${INSTALL_DIR} - - echo "BLAS: Unpacking archive..." - pushd ${BUILD_DIR} - ${TAR?} xzf ${SRCDIR}/dist/${TARNAME}.tgz - - echo "BLAS: Configuring..." - cd ${TARNAME}/BLAS/SRC - - echo "BLAS: Building..." - if echo ${F77} | grep -i xlf > /dev/null 2>&1; then - FIXEDF77FLAGS=-qfixed - fi - #${F77} ${F77FLAGS} ${FIXEDF77FLAGS} -c *.f - #${AR} ${ARFLAGS} libblas.a *.o - #if [ ${USE_RANLIB} = 'yes' ]; then - # ${RANLIB} ${RANLIBFLAGS} libblas.a - #fi - cat > make.cactus < ${DONE_FILE} - echo "BLAS: Done." - ) - if (( $? )); then - echo 'BEGIN ERROR' - echo 'Error while building BLAS. Aborting.' - echo 'END ERROR' - exit 1 - fi - fi - -fi - - - ################################################################################ # Configure Cactus ################################################################################ -# Set options -if [ "${BLAS_DIR}" != '/usr/lib' -a "${BLAS_DIR}" != '/usr/local/lib' -a \ - "${BLAS_DIR}" != 'NO_BUILD' ] -then - : ${BLAS_INC_DIRS=} - : ${BLAS_LIB_DIRS="${BLAS_DIR}"} -fi -: ${BLAS_LIBS='blas'} +pkg-config --exists blas || exit 1 +BLAS_INC_DIRS=$(pkg-config --cflags-only-I blas | sed 's/-I//g') +BLAS_LIB_DIRS=$(pkg-config --libs-only-L blas | sed 's/-L//g') +BLAS_LIBS=$(pkg-config --libs-only-l blas | sed 's/-l//g') # Pass options to Cactus echo "BEGIN MAKE_DEFINITION" -- cgit v1.2.3