This repository has been archived by the owner on Jul 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 153
/
configure
executable file
·321 lines (251 loc) · 8.45 KB
/
configure
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#!/usr/bin/env bash
#
# Manta - Structural Variant and Indel Caller
# Copyright (c) 2013-2016 Illumina, Inc.
#
# 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/>.
#
#
#
# Top level configuration file for *nix like OS's, note that there
# is legacy support for both cygwin and minGW in here but neither
# have been supported for serveral years.
#
set -o nounset
set -o pipefail
usage()
{
cat <<EOF
Manta SV caller build configuration
Usage: $0 [options]
Options: [defaults in brackets after descriptions]
Configuration:
--help print this message
--verbose display more information (enables CMAKE_VERBOSE_MAKEFILE)
--jobs=N build cmake and boost in N parallel jobs if needed [$parallel_jobs]
--with-cmake=CMAKE specify the cmake executable [cmake]
--with-eclipse create the eclipse project files
--with-version-control create the eclipse project in the source tree to
allow version control within eclipse
--build-type=TYPE specify the build type for CMake (affects compiler
options). Allowed values are "Debug", "Release",
"RelWithDebInfo", "ASan", "GCov" [$build_type]
Debug: No optimization and all debug symbols
Release: All portable optimization
RelWithDebInfo: Most optimizations, try to keep stack trace info
ASan: Light optimization with google address sanitizer on
GCov: Debug mode with code coverage options to enable gcov
Directory and file names:
--prefix=PREFIX install files in tree rooted at PREFIX
[$prefix_dir]
Some influential environment variables:
BOOST_ROOT root location of the boost library and headers
CC C compiler command
CXX C++ compiler command
Use these variables to override the choices made by 'configure' or to help
it to find libraries and programs with nonstandard names/locations. Typically
CC and CXX must be provided together to refer to the c and c++ front-ends of
the same compiler to ensure a successful build.
EOF
exit 2
# CXXFLAGS C++ compiler flags
# LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
# nonstandard directory <lib dir>
# CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
# headers in a nonstandard directory <include dir>
# CMAKE_OPTIONS CMake command line options
}
#
# utilities:
#
clog ()
{
echo $@ 1>&2
}
# rel to absolute path. works for existing paths only
rel2abs ()
{
(cd "$1" && pwd -P)
}
# Helper function to fix windows paths.
fix_slashes ()
{
echo "$1" | sed 's/\\/\//g'
}
create_path ()
{
mkdir -p "$1" || exit 1
rel2abs "$1" || exit 1
}
#
# Detect system and directory information.
#
system="`uname`"
processor="`uname -p`"
arch="`uname -a`"
root_dir="`echo $0 | sed -n '/\//{s/\/[^\/]*$//;p;}'`"
root_dir="$(rel2abs $root_dir)"
redist_dir="${root_dir}/redist"
bootstrap_dir="${root_dir}/src/cmake/bootstrap"
build_dir="$(pwd -P)"
# Determine whether this is a MinGW environment.
system_mingw=false
if echo "${system}" | grep MINGW >/dev/null 2>&1; then
system_mingw=true
fi
# Determine whether this is OS X
system_darwin=false
if echo "${system}" | grep Darwin >/dev/null 2>&1; then
system_darwin=true
fi
# Choose the default install prefix.
get_default_prefix() {
if ${system_mingw}; then
if [ "x${PROGRAMFILES}" != "x" ]; then
echo `fix_slashes "${PROGRAMFILES}/CMake"`
elif [ "x${ProgramFiles}" != "x" ]; then
echo `fix_slashes "${ProgramFiles}/CMake"`
elif [ "x${SYSTEMDRIVE}" != "x" ]; then
echo `fix_slashes "${SYSTEMDRIVE}/Program Files/CMake"`
elif [ "x${SystemDrive}" != "x" ]; then
echo `fix_slashes "${SystemDrive}/Program Files/CMake"`
else
echo "c:/Program Files/CMake"
fi
else
echo "/usr/local"
fi
}
#
# defaults:
#
prefix_dir=$(get_default_prefix)
build_type=Release
cmake=
parallel_jobs=1
cmake_generator="Unix Makefiles"
is_verbose=false
if [ -z "${CMAKE_OPTIONS+xxx}" ]; then CMAKE_OPTIONS=""; fi
# Parse arguments
for a in "$@"; do
if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then
prefix_dir=`echo $a | sed "s/^--prefix=//"`
prefix_dir=`fix_slashes "${prefix_dir}"`
elif echo $a | grep "^--help" > /dev/null 2> /dev/null; then
usage
elif echo $a | grep "^-h" > /dev/null 2> /dev/null; then
usage
elif echo $a | grep "^--with-cmake=" > /dev/null 2> /dev/null; then
cmake=`echo $a | sed "s/^--with-cmake=//"`
cmake=`fix_slashes "${cmake}"`
elif echo $a | grep "^--build-type=" > /dev/null 2> /dev/null; then
build_type=`echo $a | sed "s/^--build-type=//"`
elif echo $a | grep "^--with-eclipse" > /dev/null 2> /dev/null; then
cmake_generator="Eclipse CDT4 - Unix Makefiles"
elif echo $a | grep "^--with-version-control" > /dev/null 2> /dev/null; then
CMAKE_OPTIONS="$CMAKE_OPTIONS -DECLIPSE_CDT4_GENERATE_SOURCE_PROJECT=TRUE"
elif echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then
is_verbose=true
elif echo $a | grep "^--jobs=" > /dev/null 2> /dev/null; then
parallel_jobs=`echo $a | sed "s/^--jobs=//"`
else
clog "ERROR: unknown argument: $a"
exit 2
fi
done
#
# prevent in-source builds (but allow usage to be triggered first)
#
if [ "$root_dir" == "$build_dir" ]; then
cat <<EOF 1>&2
ERROR: This project cannot be built in the source directory. Please run
configuration in a separate directory. Example:
"""
mkdir ../build && cd ../build
\${MANTA_ROOT_PATH}/configure [configure_options]
"""
EOF
exit 1
fi
#
# setup cmake options
#
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_BUILD_TYPE:STRING=${build_type}"
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_PARALLEL:STRING=${parallel_jobs}"
if $is_verbose; then
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DBoost_DEBUG:BOOL=ON"
fi
if [ "x${prefix_dir}" != "x" ]; then prefix_dir=$(create_path "${prefix_dir}") || exit 1; fi
CMAKE_OPTIONS="-DCMAKE_INSTALL_PREFIX:PATH=\"$prefix_dir\" $CMAKE_OPTIONS"
# create the build directory if necessary
if ! [ -d "${build_dir}" ]; then
mkdir "${build_dir}"
if [ "$?" != 0 ]; then
clog "ERROR: Couldn't create the build directory: ${build_dir}"
exit 1
fi
fi
#
# install cmake if required:
#
cmake_install_dir="${build_dir}/bootstrap/cmake"
if [ "x${cmake}" == "x" ] ; then
cmake=$(bash ${bootstrap_dir}/installCmake.bash ${redist_dir} ${cmake_install_dir} ${parallel_jobs})
if [ "$?" != "0" ]; then
clog "ERROR: Failed to verify or install cmake"
exit 1
fi
bootstrapped_cmake="${cmake_install_dir}/bin/cmake"
if [ $cmake == $bootstrapped_cmake ]; then
echo "Using installed cmake: $cmake"
else
echo "Using existing cmake: $cmake"
fi
fi
# display information if required
if $is_verbose; then
cat<<EOF
Source directory: ${root_dir}
Prefix directory: ${prefix_dir}
Build directory: ${build_dir}
Cmake executable: ${cmake}
EOF
fi
#
# finally, invoke cmake
#
cmake_command="${cmake} -H\"${root_dir}\" -B\"${build_dir}\" -G\"${cmake_generator}\" ${CMAKE_OPTIONS}"
if $is_verbose ; then
cat<<EOF
Running on: $arch
Configuring the build directory with:
$cmake_command
EOF
fi
eval $cmake_command
if [ "$?" != 0 ]; then
cat<<EOF 1>&2
Couldn't configure the project:
$cmake_command
Moving CMakeCache.txt to CMakeCache.txt.removed
EOF
if [ -f ${build_dir}/CMakeCache.txt ]; then
rm -f ${build_dir}/CMakeCache.txt.removed && mv ${build_dir}/CMakeCache.txt ${build_dir}/CMakeCache.txt.removed
fi
exit 1
fi
cat<<EOF
The build directory ${build_dir} was configured successfully
Type "make -C ${build_dir}" to build
EOF