File: configure

package info (click to toggle)
tiledarray 0.6.0-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,804 kB
  • ctags: 5,213
  • sloc: cpp: 31,686; sh: 237; ansic: 227; makefile: 53; python: 12
file content (218 lines) | stat: -rwxr-xr-x 7,750 bytes parent folder | download | duplicates (2)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/bin/sh

#
#  This file is a part of TiledArray.
#  Copyright (C) 2013  Virginia Tech
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#  Justus Calvin
#  Department of Chemistry, Virginia Tech
#
#  configure
#  Jul 19, 2013
#

TOPDIR=$(cd `dirname $0` && pwd)
#echo $TOPDIR

# Strip prefix from argument
arg () {
  echo "$1" | sed "s/^${2-[^=]*=}//"
}

# Display CMake bootstrap usage
help()
{
echo '
Configure TiledArray. This script will invoke cmake.
Alternatively, use cmake or ccmake directly.

Invoked as "configure cmake" it will download and install cmake into ./cmake directory 

Usage: '"$0"' [<options>...]
Options: [defaults in brackets after descriptions]
Configuration:
  --help                  print this message
  --prefix=               install prefix (CMAKE_INSTALL_PREFIX=)
  --debug                 debug build (CMAKE_BUILD_TYPE=Debug)
  --unittest              build unit tests (TA_BUILD_UNITTEST=TRUE)
  --lapack=               LAPACK libraries (LAPACK_LIBRARIES=)
  --blas=                 BLAS libraries (BLAS_LIBRARIES=)
  --integer8              Use integer*8 Fortran integers in BLAS calls. If this option
                          is not given, integer*4 Fortran integers are used in BLAS
                          calls. (INTEGER4=FALSE)
  --mpicc=                MPI C compiler to deduce MPI environment,
                          only needed if CXX is not set to an MPI compiler wrapper
                          (MPI_C_COMPILER=)
  --mpicxx=               MPI C++ compiler to deduce MPI environment,
                          only needed if CXX is not set to an MPI compiler wrapper
                          (MPI_CXX_COMPILER=)
  --disable-mpi           Disable checks and inclusion of MPI (DISABLE_MPI) 
  --boost=                Boost path, only needed if --unittest is set also (BOOST_ROOT=)
  --madness=              MADNESS path (MADNESS_ROOT_DIR=)
  --tbb=                  Threading Building Blocks path (TBB_ROOT_DIR=)
  --tbb-include=          Threading Building Blocks include path (TBB_INCLUDE_DIR=)
  --tbb-library=          Threading Building Blocks library path (TBB_LIBRARY=)
  --elemental=            compile Elemental as part of MADNESS (ENABLE_ELEMENTAL=TRUE,
                          ELEMENTAL_TAG=) 
  --error-checking=       specify the default error reporting style,
                          allowed values: none, throw (default), assert
                          (TA_ERROR=)
  --search=               paths to search for files/libraries, separated by semicolon;
                          specify here the locations of Eigen, MADNESS unless you want
                          configure to download and build them automatically
                          (CMAKE_PREFIX_PATH=)
  --expert                Expert mode: disables building dependencies, e.g. Eigen,
                          MADNESS, etc. (TA_EXPERT=TRUE)
  -D*                     passed verbatim to cmake command

Some influential environment variables:
  CPPFLAGS    C/C++ proprocessor flags     (e.g. CPPFLAGS='-I/opt/local/include -DNDEBUG')
  LDFLAGS     linker flags                 (e.g. LDFLAGS=-L/libdir)
  CXX         C++ compiler command         (e.g. CXX='mpicxx')
  CXXFLAGS    C++ compiler flags           (e.g. CXXFLAGS='-O0 -g -std=c++0x')
  F77         Fortran 77 compiler command  (e.g. F77='gfortran')
  FFLAGS      Fortran 77 compiler flags    (e.g. FFLAGS='-fdefault-integer-8')
  CC          C compiler command           (e.g. CC='mpicc')
  CFLAGS      C compiler flags             (e.g. CFLAGS='-O0 -g -std=c11')
'
  exit 1
}

# was told to build local cmake
if [ $# -eq 1 -a "$1" = "cmake" ]; then
    cd $TOPDIR/cmake && make cmake
    exit
fi

# check if local cmake was built
CMAKE=$TOPDIR/cmake/bin/cmake
if [ ! -x "$CMAKE" ]; then
    CMAKE=`which cmake 2>/dev/null`
fi

# if no local/system cmake exist, build!
if [ -z "$CMAKE" ]; then
    make -C cmake
    CMAKE=$TOPDIR/cmake/bin/cmake
fi

srcdir=`dirname $0`
echo $srcdir
args=""
prefix=$PWD
build="Release"

# log the command-line arguments, preserving quotes
log="#!/bin/sh\n# Last invoked on `date`:\n$0 "
for token in "$@"
  do
    log="$log '$token'"
  done

while test $# != 0; do
  case "$1" in
  --help|-h) help ;;
  --prefix=*)      prefix="`arg \"$1\"`" ;;
  --lapack=*)      lapack="`arg \"$1\"`"
                   args="$args -DLAPACK_LIBRARIES=\"$lapack\"" ;;
  --blas=*)        blas="`arg \"$1\"`"
                   args="$args -DBLAS_LIBRARIES=\"$blas\"" ;;
  --integer8)      args="$args -DINTEGER4=FALSE" ;;
  --debug)         build="Debug" ;; #args="$args -DCMAKE_BUILD_TYPE=Debug" ;;
  --search=*)      search="`arg \"$1\"`"
                   args="$args -DCMAKE_PREFIX_PATH=\"$search\"" ;;
  --mpicc=*)       args="$args -DMPI_C_COMPILER=`arg \"$1\"`" ;;
  --mpicxx=*)      args="$args -DMPI_CXX_COMPILER=`arg \"$1\"`" ;;
  --disable-mpi)   args="$args -DENABLE_MPI=OFF" ;;
  --unittest)      args="$args -DTA_BUILD_UNITTEST=TRUE" ;;
  --boost=*)       args="$args -DBOOST_ROOT=`arg \"$1\"`" ;;
  --madness=*)     args="$args -DMADNESS_ROOT_DIR=`arg \"$1\"`" ;;
  --tbb=*)         args="$args -DTBB_ROOT_DIR=`arg \"$1\"`" ;;
  --tbb-include=*) args="$args -DTBB_INCLUDE_DIR=`arg \"$1\"`" ;;
  --tbb-library=*) args="$args -DTBB_LIBRARY=`arg \"$1\"`" ;;
  --elemental)     args="$args -DENABLE_ELEMENTAL=1" ;;
  --elemental=*)   args="$args -DENABLE_ELEMENTAL=1 -DELEMENTAL_TAG=`arg \"$1\"`" ;;
  --error-checking=*)   args="$args -DTA_ERROR=`arg \"$1\"`" ;;
  --expert)        args="$args -DTA_EXPERT=TRUE" ;;
  -D*) args="$args $1" ;; # raw  cmake arg
  CC=*) CC="`arg \"$1\"`" ;;
  CXX=*) CXX="`arg \"$1\"`" ;;
  F77=*) F77="`arg \"$1\"`" ;;
  CPPFLAGS=*) CPPFLAGS="`arg \"$1\"`" ;;
  CFLAGS=*) CFLAGS="`arg \"$1\"`" ;;
  CXXFLAGS=*) CXXFLAGS="`arg \"$1\"`" ;;
  FFLAGS=*) FFLAGS="`arg \"$1\"`" ;;
  LDFLAGS=*) LDFLAGS="`arg \"$1\"`" ;;
  *) exit "Unknown option: \"$1\"" ;;
  esac
  shift
done

# dump command-line arguments into reconf.sh
echo $log > reconf.sh
chmod +x reconf.sh

args="$args -DCMAKE_INSTALL_PREFIX=$prefix"
args="$args -DCMAKE_BUILD_TYPE=$build"

if [ -n "$CC" ]; then
    args="$args -DCMAKE_C_COMPILER=$CC"
fi

if [ -n "$CXX" ]; then
    args="$args -DCMAKE_CXX_COMPILER=$CXX"
fi

if [ -n "$F77" ]; then
    args="$args -DCMAKE_Fortran_COMPILER=$F77"
fi

if [ -n "$CPPFLAGS" ]; then
    args="$args -DCMAKE_CPP_FLAGS=\"$CPPFLAGS\""
fi

# to add CPPFLAGS properly in cmake would need to parse it into defines and includes, etc.
# easiest to just merge all into CFLAGS/CXXFLAGS
if [ -n "$CFLAGS" ]; then
  if [ -n "$CPPFLAGS" ]; then
    args="$args -DCMAKE_C_FLAGS=\"$CFLAGS $CPPFLAGS\""
  else
    args="$args -DCMAKE_C_FLAGS=\"$CFLAGS\""
  fi
fi

if [ -n "$CXXFLAGS" ]; then
  if [ -n "$CPPFLAGS" ]; then
    args="$args -DCMAKE_CXX_FLAGS=\"$CXXFLAGS $CPPFLAGS\""
  else
    args="$args -DCMAKE_CXX_FLAGS=\"$CXXFLAGS\""
  fi
fi

if [ -n "$FFLAGS" ]; then
    args="$args -DCMAKE_Fortran_FLAGS=\"$FFLAGS\""
fi

if [ -n "$LDFLAGS" ]; then
    args="$args -DCMAKE_EXE_LINKER_FLAGS=\"$LDFLAGS\""
fi

echo "Using CMake $CMAKE"
cmd="$CMAKE $args $srcdir"

set -x
rm -fr CMakeFiles CMakeCache.txt
eval $cmd