summaryrefslogtreecommitdiff
path: root/lib/make/extras/BLAS/setup.sh
blob: ef81ceb6cb2bf95acfc82aa284ac1dbc62a58514 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /bin/sh
# /*@@
#   @file      setup.sh
#   @date      Sat May 31 17:56:34 CEST 2003
#   @author    Jonathan Thornburg, borrowing ++heavily from
#              Thomas Radke's LAPACK setup.sh
#   @desc
#              Setup for compilation with the BLAS library system installation
#              See http://www.netlib.org/blas/ for more info on the BLAS.
#   @enddesc
#   @version   $Header$
# @@*/

choose_blas=`echo $BLAS | tr '[:upper:]' '[:lower:]'`

if test "X$choose_blas" = 'Xyes' ; then

  echo 'Configuring with BLAS'

  # Search for BLAS installation
  if test -z "$BLAS_DIR"; then
    echo 'BLAS selected but no BLAS_DIR set... Checking some places'
    CCTK_Search BLAS_DIR '/usr/lib /usr/local/lib' libblas.a
    if test -z "$BLAS_DIR"; then
      CCTK_Search BLAS_DIR '/usr/lib /usr/local/lib' libblas.so
    fi
    if test -z "$BLAS_DIR"; then
      echo 'Unable to locate the BLAS library - please set BLAS_DIR'
      exit 2
    fi
    echo "Found a BLAS package in $BLAS_DIR"
    # don't explicitely add standard include and library search paths
    if [ "$BLAS_DIR" = '/usr/lib' -o "$BLAS_DIR" = '/usr/local/lib' ]; then
      BLAS_DIR=''
    fi
  elif test "$BLAS_DIR" = 'none'; then
    # user doesn't want the library path added
    BLAS_DIR=''
  fi

  if test -z "$BLAS_LIBS"; then
    BLAS_LIBS='blas'
  fi

  # write the variables out to the header and makefiles
  CCTK_WriteLine cctk_Extradefs.h '#define CCTK_BLAS 1'

  CCTK_WriteLine make.extra.defn "HAVE_BLAS     = 1"
  CCTK_WriteLine make.extra.defn "BLAS_LIBS     = $BLAS_LIBS $BLAS_EXTRA_LIBS m"
  CCTK_WriteLine make.extra.defn "BLAS_LIB_DIRS = $BLAS_DIR $BLAS_EXTRA_LIB_DIRS"
  CCTK_WriteLine make.extra.defn ''
  CCTK_WriteLine make.extra.defn 'LIBS           += $(BLAS_LIBS)'
  CCTK_WriteLine make.extra.defn 'LIBDIRS        += $(BLAS_LIB_DIRS)'

elif test "X$choose_blas" != 'Xno' -a "X$choose_blas" != 'X'; then

  echo "Don't understand the setting \"BLAS=$BLAS\" !"
  echo 'Please set it to either "yes" or "no", or leave it blank (same as "no") !'
  exit 1

fi