0db8659cada7264c7b868a009c741791b05dc2bb
[cvc5.git] / configure.sh
1 #!/bin/bash
2 #--------------------------------------------------------------------------#
3
4 set -e -o pipefail
5
6 usage () {
7 cat <<EOF
8 Usage: $0 [<build type>] [<option> ...]
9
10 Build types:
11 production
12 debug
13 testing
14 competition
15 competition-inc
16
17
18 General options;
19 -h, --help display this help and exit
20 --prefix=STR install directory
21 --program-prefix=STR prefix of binaries prepended on make install
22 --name=STR use custom build directory name (optionally: +path)
23 --best turn on dependencies and options known to give best performance
24 --gpl permit GPL dependencies, if available
25 --arm64 cross-compile for Linux ARM 64 bit
26 --win64 cross-compile for Windows 64 bit
27 --ninja use Ninja build system
28 --docs build Api documentation
29
30
31 Features:
32 The following flags enable optional features (disable with --no-<option name>).
33 --static build static libraries and binaries [default=no]
34 --static-binary statically link against system libraries
35 (must be disabled for static macOS builds) [default=yes]
36 --auto-download automatically download dependencies if necessary
37 --debug-symbols include debug symbols
38 --valgrind Valgrind instrumentation
39 --debug-context-mm use the debug context memory manager
40 --statistics include statistics
41 --assertions turn on assertions
42 --tracing include tracing code
43 --dumping include dumping code
44 --muzzle complete silence (no non-result output)
45 --coverage support for gcov coverage testing
46 --profiling support for gprof profiling
47 --unit-testing support for unit testing
48 --python2 force Python 2 (deprecated)
49 --python-bindings build Python bindings based on new C++ API
50 --java-bindings build Java bindings based on new C++ API
51 --all-bindings build bindings for all supported languages
52 --asan build with ASan instrumentation
53 --ubsan build with UBSan instrumentation
54 --tsan build with TSan instrumentation
55 --werror build with -Werror
56 --ipo build with interprocedural optimization
57
58 Optional Packages:
59 The following flags enable optional packages (disable with --no-<option name>).
60 --cln use CLN instead of GMP
61 --glpk use GLPK simplex solver
62 --abc use the ABC AIG library
63 --cryptominisat use the CryptoMiniSat SAT solver
64 --kissat use the Kissat SAT solver
65 --poly use the LibPoly library [default=yes]
66 --cocoa use the CoCoA library
67 --editline support the editline library
68
69 Optional Path to Optional Packages:
70 --abc-dir=PATH path to top level of ABC source tree
71 --glpk-dir=PATH path to top level of GLPK installation
72 --dep-path=PATH path to a dependency installation dir
73
74 Build limitations:
75 --lib-only only build the library, but not the executable or
76 the parser (default: off)
77
78 CMake Options (Advanced)
79 -DVAR=VALUE manually add CMake options
80
81 EOF
82 exit 0
83 }
84
85 #--------------------------------------------------------------------------#
86
87 die () {
88 echo "*** configure.sh: $*" 1>&2
89 exit 1
90 }
91
92 msg () {
93 echo "[configure.sh] $*"
94 }
95
96 #--------------------------------------------------------------------------#
97
98 [ ! -e src/theory ] && die "$0 not called from CVC4 base directory"
99
100 #--------------------------------------------------------------------------#
101
102 build_dir=build
103 install_prefix=default
104 program_prefix=""
105
106 #--------------------------------------------------------------------------#
107
108 buildtype=default
109
110 abc=default
111 asan=default
112 assertions=default
113 auto_download=default
114 cln=default
115 comp_inc=default
116 coverage=default
117 cryptominisat=default
118 debug_context_mm=default
119 debug_symbols=default
120 docs=default
121 dumping=default
122 glpk=default
123 gpl=default
124 kissat=default
125 poly=ON
126 cocoa=default
127 muzzle=default
128 ninja=default
129 profiling=default
130 python2=default
131 python_bindings=default
132 java_bindings=default
133 editline=default
134 shared=default
135 static_binary=default
136 statistics=default
137 tracing=default
138 tsan=default
139 ubsan=default
140 unit_testing=default
141 valgrind=default
142 win64=default
143 arm64=default
144 werror=default
145 ipo=default
146
147 abc_dir=default
148 glpk_dir=default
149
150 lib_only=default
151
152 #--------------------------------------------------------------------------#
153
154 cmake_opts=""
155
156 while [ $# -gt 0 ]
157 do
158 case $1 in
159
160 -h|--help) usage;;
161
162 --abc) abc=ON;;
163 --no-abc) abc=OFF;;
164
165 --asan) asan=ON;;
166 --no-asan) asan=OFF;;
167
168 --ubsan) ubsan=ON;;
169 --no-ubsan) ubsan=OFF;;
170
171 --tsan) tsan=ON;;
172 --no-tsan) tsan=OFF;;
173
174 --werror) werror=ON;;
175
176 --ipo) ipo=ON;;
177 --no-ipo) ipo=OFF;;
178
179 --assertions) assertions=ON;;
180 --no-assertions) assertions=OFF;;
181
182 # Best configuration
183 --best)
184 ipo=ON
185 abc=ON
186 cln=ON
187 cryptominisat=ON
188 glpk=ON
189 editline=ON
190 ;;
191
192 --prefix) die "missing argument to $1 (try -h)" ;;
193 --prefix=*)
194 install_prefix=${1##*=}
195 # Check if install_prefix is an absolute path and if not, make it
196 # absolute.
197 case $install_prefix in
198 /*) ;; # absolute path
199 *) install_prefix=$(pwd)/$install_prefix ;; # make absolute path
200 esac
201 ;;
202
203 --program-prefix) die "missing argument to $1 (try -h)" ;;
204 --program-prefix=*) program_prefix=${1##*=} ;;
205
206 --name) die "missing argument to $1 (try -h)" ;;
207 --name=*) build_dir=${1##*=} ;;
208
209 --cln) cln=ON;;
210 --no-cln) cln=OFF;;
211
212 --coverage) coverage=ON;;
213 --no-coverage) coverage=OFF;;
214
215 --cryptominisat) cryptominisat=ON;;
216 --no-cryptominisat) cryptominisat=OFF;;
217
218 --debug-symbols) debug_symbols=ON;;
219 --no-debug-symbols) debug_symbols=OFF;;
220
221 --debug-context-mm) debug_context_mm=ON;;
222 --no-debug-context-mm) debug_context_mm=OFF;;
223
224 --dumping) dumping=ON;;
225 --no-dumping) dumping=OFF;;
226
227 --gpl) gpl=ON;;
228 --no-gpl) gpl=OFF;;
229
230 --kissat) kissat=ON;;
231 --no-kissat) kissat=OFF;;
232
233 --win64) win64=ON;;
234
235 --arm64) arm64=ON;;
236
237 --ninja) ninja=ON;;
238
239 --docs) docs=ON;;
240 --no-docs) docs=OFF;;
241
242 --glpk) glpk=ON;;
243 --no-glpk) glpk=OFF;;
244
245 --poly) poly=ON;;
246 --no-poly) poly=OFF;;
247
248 --cocoa) cocoa=ON;;
249 --no-cocoa) cocoa=OFF;;
250
251 --muzzle) muzzle=ON;;
252 --no-muzzle) muzzle=OFF;;
253
254 --static) shared=OFF; static_binary=ON;;
255 --no-static) shared=ON;;
256
257 --static-binary) static_binary=ON;;
258 --no-static-binary) static_binary=OFF;;
259
260 --auto-download) auto_download=ON;;
261 --no-auto-download) auto_download=OFF;;
262
263 --statistics) statistics=ON;;
264 --no-statistics) statistics=OFF;;
265
266 --tracing) tracing=ON;;
267 --no-tracing) tracing=OFF;;
268
269 --unit-testing) unit_testing=ON;;
270 --no-unit-testing) unit_testing=OFF;;
271
272 --python2) python2=ON;;
273 --no-python2) python2=OFF;;
274
275 --python-bindings) python_bindings=ON;;
276 --no-python-bindings) python_bindings=OFF;;
277
278 --java-bindings) java_bindings=ON;;
279 --no-java-bindings) java_bindings=OFF;;
280
281 --all-bindings)
282 python_bindings=ON
283 java_bindings=ON;;
284
285 --valgrind) valgrind=ON;;
286 --no-valgrind) valgrind=OFF;;
287
288 --profiling) profiling=ON;;
289 --no-profiling) profiling=OFF;;
290
291 --editline) editline=ON;;
292 --no-editline) editline=OFF;;
293
294 --abc-dir) die "missing argument to $1 (try -h)" ;;
295 --abc-dir=*) abc_dir=${1##*=} ;;
296
297 --glpk-dir) die "missing argument to $1 (try -h)" ;;
298 --glpk-dir=*) glpk_dir=${1##*=} ;;
299
300 --dep-path) die "missing argument to $1 (try -h)" ;;
301 --dep-path=*) dep_path="${dep_path};${1##*=}" ;;
302
303 --lib-only) lib_only=ON ;;
304 -D*) cmake_opts="${cmake_opts} $1" ;;
305
306 -*) die "invalid option '$1' (try -h)";;
307
308 *) case $1 in
309 production) buildtype=Production;;
310 debug) buildtype=Debug;;
311 testing) buildtype=Testing;;
312 competition) buildtype=Competition;;
313 competition-inc) buildtype=Competition; comp_inc=ON;;
314 *) die "invalid build type (try -h)";;
315 esac
316 ;;
317 esac
318 shift
319 done
320
321 #--------------------------------------------------------------------------#
322
323 if [ $werror != default ]; then
324 export CFLAGS=-Werror
325 export CXXFLAGS=-Werror
326 fi
327
328 [ $buildtype != default ] \
329 && cmake_opts="$cmake_opts -DCMAKE_BUILD_TYPE=$buildtype"
330
331 [ $asan != default ] \
332 && cmake_opts="$cmake_opts -DENABLE_ASAN=$asan"
333 [ $auto_download != default ] \
334 && cmake_opts="$cmake_opts -DENABLE_AUTO_DOWNLOAD=$auto_download"
335 [ $ubsan != default ] \
336 && cmake_opts="$cmake_opts -DENABLE_UBSAN=$ubsan"
337 [ $tsan != default ] \
338 && cmake_opts="$cmake_opts -DENABLE_TSAN=$tsan"
339 [ $ipo != default ] \
340 && cmake_opts="$cmake_opts -DENABLE_IPO=$ipo"
341 [ $assertions != default ] \
342 && cmake_opts="$cmake_opts -DENABLE_ASSERTIONS=$assertions"
343 [ $comp_inc != default ] \
344 && cmake_opts="$cmake_opts -DENABLE_COMP_INC_TRACK=$comp_inc"
345 [ $coverage != default ] \
346 && cmake_opts="$cmake_opts -DENABLE_COVERAGE=$coverage"
347 [ $debug_symbols != default ] \
348 && cmake_opts="$cmake_opts -DENABLE_DEBUG_SYMBOLS=$debug_symbols"
349 [ $debug_context_mm != default ] \
350 && cmake_opts="$cmake_opts -DENABLE_DEBUG_CONTEXT_MM=$debug_context_mm"
351 [ $dumping != default ] \
352 && cmake_opts="$cmake_opts -DENABLE_DUMPING=$dumping"
353 [ $gpl != default ] \
354 && cmake_opts="$cmake_opts -DENABLE_GPL=$gpl"
355 [ $win64 != default ] \
356 && cmake_opts="$cmake_opts -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw64.cmake"
357 [ $arm64 != default ] \
358 && cmake_opts="$cmake_opts -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-aarch64.cmake"
359 [ $ninja != default ] && cmake_opts="$cmake_opts -G Ninja"
360 [ $muzzle != default ] \
361 && cmake_opts="$cmake_opts -DENABLE_MUZZLE=$muzzle"
362 [ $shared != default ] \
363 && cmake_opts="$cmake_opts -DENABLE_SHARED=$shared"
364 [ $static_binary != default ] \
365 && cmake_opts="$cmake_opts -DENABLE_STATIC_BINARY=$static_binary"
366 [ $statistics != default ] \
367 && cmake_opts="$cmake_opts -DENABLE_STATISTICS=$statistics"
368 [ $tracing != default ] \
369 && cmake_opts="$cmake_opts -DENABLE_TRACING=$tracing"
370 [ $unit_testing != default ] \
371 && cmake_opts="$cmake_opts -DENABLE_UNIT_TESTING=$unit_testing"
372 [ $python2 != default ] \
373 && cmake_opts="$cmake_opts -DUSE_PYTHON2=$python2"
374 [ $docs != default ] \
375 && cmake_opts="$cmake_opts -DBUILD_DOCS=$docs"
376 [ $python_bindings != default ] \
377 && cmake_opts="$cmake_opts -DBUILD_BINDINGS_PYTHON=$python_bindings"
378 [ $java_bindings != default ] \
379 && cmake_opts="$cmake_opts -DBUILD_BINDINGS_JAVA=$java_bindings"
380 [ $valgrind != default ] \
381 && cmake_opts="$cmake_opts -DENABLE_VALGRIND=$valgrind"
382 [ $profiling != default ] \
383 && cmake_opts="$cmake_opts -DENABLE_PROFILING=$profiling"
384 [ $editline != default ] \
385 && cmake_opts="$cmake_opts -DUSE_EDITLINE=$editline"
386 [ $abc != default ] \
387 && cmake_opts="$cmake_opts -DUSE_ABC=$abc"
388 [ $cln != default ] \
389 && cmake_opts="$cmake_opts -DUSE_CLN=$cln"
390 [ $cryptominisat != default ] \
391 && cmake_opts="$cmake_opts -DUSE_CRYPTOMINISAT=$cryptominisat"
392 [ $glpk != default ] \
393 && cmake_opts="$cmake_opts -DUSE_GLPK=$glpk"
394 [ $kissat != default ] \
395 && cmake_opts="$cmake_opts -DUSE_KISSAT=$kissat"
396 [ $poly != default ] \
397 && cmake_opts="$cmake_opts -DUSE_POLY=$poly"
398 [ $cocoa != default ] \
399 && cmake_opts="$cmake_opts -DUSE_COCOA=$cocoa"
400 [ "$abc_dir" != default ] \
401 && cmake_opts="$cmake_opts -DABC_DIR=$abc_dir"
402 [ "$glpk_dir" != default ] \
403 && cmake_opts="$cmake_opts -DGLPK_DIR=$glpk_dir"
404 [ "$dep_path" != default ] \
405 && cmake_opts="$cmake_opts -DCMAKE_PREFIX_PATH=$dep_path"
406 [ "$lib_only" != default ] \
407 && cmake_opts="$cmake_opts -DBUILD_LIB_ONLY=$lib_only"
408 [ "$install_prefix" != default ] \
409 && cmake_opts="$cmake_opts -DCMAKE_INSTALL_PREFIX=$install_prefix"
410 [ -n "$program_prefix" ] \
411 && cmake_opts="$cmake_opts -DPROGRAM_PREFIX=$program_prefix"
412
413 root_dir=$(pwd)
414
415 # The cmake toolchain can't be changed once it is configured in $build_dir.
416 # Thus, remove $build_dir and create an empty directory.
417 [ $win64 = ON ] && [ -e "$build_dir" ] && rm -r "$build_dir"
418 [ $arm64 = ON ] && [ -e "$build_dir" ] && rm -r "$build_dir"
419 mkdir -p "$build_dir"
420
421 cd "$build_dir"
422
423 [ -e CMakeCache.txt ] && rm CMakeCache.txt
424 build_dir_escaped=$(echo "$build_dir" | sed 's/\//\\\//g')
425 cmake "$root_dir" $cmake_opts 2>&1 | \
426 sed "s/^Now just/Now change to '$build_dir_escaped' and/"