Fix spurious antecedant for symbolic regular expressions (#6284)
[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 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
29
30 Features:
31 The following flags enable optional features (disable with --no-<option name>).
32 --static build static libraries and binaries [default=no]
33 --static-binary statically link against system libraries
34 (must be disabled for static macOS builds) [default=yes]
35 --debug-symbols include debug symbols
36 --valgrind Valgrind instrumentation
37 --debug-context-mm use the debug context memory manager
38 --statistics include statistics
39 --assertions turn on assertions
40 --tracing include tracing code
41 --dumping include dumping code
42 --muzzle complete silence (no non-result output)
43 --coverage support for gcov coverage testing
44 --profiling support for gprof profiling
45 --unit-testing support for unit testing
46 --python2 force Python 2 (deprecated)
47 --python-bindings build Python bindings based on new C++ API
48 --java-bindings build Java bindings based on new C++ API
49 --all-bindings build bindings for all supported languages
50 --asan build with ASan instrumentation
51 --ubsan build with UBSan instrumentation
52 --tsan build with TSan instrumentation
53 --werror build with -Werror
54
55 Optional Packages:
56 The following flags enable optional packages (disable with --no-<option name>).
57 --cln use CLN instead of GMP
58 --glpk use GLPK simplex solver
59 --abc use the ABC AIG library
60 --cadical use the CaDiCaL SAT solver
61 --cryptominisat use the CryptoMiniSat SAT solver
62 --kissat use the Kissat SAT solver
63 --poly use the LibPoly library
64 --symfpu use SymFPU for floating point solver
65 --editline support the editline library
66
67 Optional Path to Optional Packages:
68 --abc-dir=PATH path to top level of ABC source tree
69 --cadical-dir=PATH path to top level of CaDiCaL source tree
70 --cryptominisat-dir=PATH path to top level of CryptoMiniSat source tree
71 --glpk-dir=PATH path to top level of GLPK installation
72 --gmp-dir=PATH path to top level of GMP installation
73 --kissat-dir=PATH path to top level of Kissat source tree
74 --poly-dir=PATH path to top level of LibPoly source tree
75 --symfpu-dir=PATH path to top level of SymFPU source tree
76
77 Build limitations:
78 --lib-only only build the library, but not the executable or
79 the parser (default: off)
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 cadical=default
114 cln=default
115 comp_inc=default
116 coverage=default
117 cryptominisat=default
118 debug_context_mm=default
119 debug_symbols=default
120 dumping=default
121 glpk=default
122 gpl=default
123 kissat=default
124 poly=default
125 muzzle=default
126 ninja=default
127 profiling=default
128 python2=default
129 python_bindings=default
130 java_bindings=default
131 editline=default
132 shared=default
133 static_binary=default
134 statistics=default
135 symfpu=default
136 tracing=default
137 tsan=default
138 ubsan=default
139 unit_testing=default
140 valgrind=default
141 win64=default
142 arm64=default
143 werror=default
144
145 abc_dir=default
146 cadical_dir=default
147 cryptominisat_dir=default
148 glpk_dir=default
149 gmp_dir=default
150 kissat_dir=default
151 poly_dir=default
152 symfpu_dir=default
153
154 lib_only=default
155
156 #--------------------------------------------------------------------------#
157
158 while [ $# -gt 0 ]
159 do
160 case $1 in
161
162 -h|--help) usage;;
163
164 --abc) abc=ON;;
165 --no-abc) abc=OFF;;
166
167 --asan) asan=ON;;
168 --no-asan) asan=OFF;;
169
170 --ubsan) ubsan=ON;;
171 --no-ubsan) ubsan=OFF;;
172
173 --tsan) tsan=ON;;
174 --no-tsan) tsan=OFF;;
175
176 --werror) werror=ON;;
177
178 --assertions) assertions=ON;;
179 --no-assertions) assertions=OFF;;
180
181 # Best configuration
182 --best)
183 abc=ON
184 cadical=ON
185 cln=ON
186 cryptominisat=ON
187 glpk=ON
188 editline=ON
189 ;;
190
191 --prefix) die "missing argument to $1 (try -h)" ;;
192 --prefix=*)
193 install_prefix=${1##*=}
194 # Check if install_prefix is an absolute path and if not, make it
195 # absolute.
196 case $install_prefix in
197 /*) ;; # absolute path
198 *) install_prefix=$(pwd)/$install_prefix ;; # make absolute path
199 esac
200 ;;
201
202 --program-prefix) die "missing argument to $1 (try -h)" ;;
203 --program-prefix=*) program_prefix=${1##*=} ;;
204
205 --name) die "missing argument to $1 (try -h)" ;;
206 --name=*) build_dir=${1##*=} ;;
207
208 --cadical) cadical=ON;;
209 --no-cadical) cadical=OFF;;
210
211 --cln) cln=ON;;
212 --no-cln) cln=OFF;;
213
214 --coverage) coverage=ON;;
215 --no-coverage) coverage=OFF;;
216
217 --cryptominisat) cryptominisat=ON;;
218 --no-cryptominisat) cryptominisat=OFF;;
219
220 --debug-symbols) debug_symbols=ON;;
221 --no-debug-symbols) debug_symbols=OFF;;
222
223 --debug-context-mm) debug_context_mm=ON;;
224 --no-debug-context-mm) debug_context_mm=OFF;;
225
226 --dumping) dumping=ON;;
227 --no-dumping) dumping=OFF;;
228
229 --gpl) gpl=ON;;
230 --no-gpl) gpl=OFF;;
231
232 --kissat) kissat=ON;;
233 --no-kissat) kissat=OFF;;
234
235 --win64) win64=ON;;
236
237 --arm64) arm64=ON;;
238
239 --ninja) ninja=ON;;
240
241 --glpk) glpk=ON;;
242 --no-glpk) glpk=OFF;;
243
244 --poly) poly=ON;;
245 --no-poly) poly=OFF;;
246
247 --muzzle) muzzle=ON;;
248 --no-muzzle) muzzle=OFF;;
249
250 --static) shared=OFF; static_binary=ON;;
251 --no-static) shared=ON;;
252
253 --static-binary) static_binary=ON;;
254 --no-static-binary) static_binary=OFF;;
255
256 --statistics) statistics=ON;;
257 --no-statistics) statistics=OFF;;
258
259 --symfpu) symfpu=ON;;
260 --no-symfpu) symfpu=OFF;;
261
262 --tracing) tracing=ON;;
263 --no-tracing) tracing=OFF;;
264
265 --unit-testing) unit_testing=ON;;
266 --no-unit-testing) unit_testing=OFF;;
267
268 --python2) python2=ON;;
269 --no-python2) python2=OFF;;
270
271 --python-bindings) python_bindings=ON;;
272 --no-python-bindings) python_bindings=OFF;;
273
274 --java-bindings) java_bindings=ON;;
275 --no-java-bindings) java_bindings=OFF;;
276
277 --all-bindings)
278 python_bindings=ON
279 java_bindings=ON;;
280
281 --valgrind) valgrind=ON;;
282 --no-valgrind) valgrind=OFF;;
283
284 --profiling) profiling=ON;;
285 --no-profiling) profiling=OFF;;
286
287 --editline) editline=ON;;
288 --no-editline) editline=OFF;;
289
290 --abc-dir) die "missing argument to $1 (try -h)" ;;
291 --abc-dir=*) abc_dir=${1##*=} ;;
292
293 --cadical-dir) die "missing argument to $1 (try -h)" ;;
294 --cadical-dir=*) cadical_dir=${1##*=} ;;
295
296 --cryptominisat-dir) die "missing argument to $1 (try -h)" ;;
297 --cryptominisat-dir=*) cryptominisat_dir=${1##*=} ;;
298
299 --glpk-dir) die "missing argument to $1 (try -h)" ;;
300 --glpk-dir=*) glpk_dir=${1##*=} ;;
301
302 --gmp-dir) die "missing argument to $1 (try -h)" ;;
303 --gmp-dir=*) gmp_dir=${1##*=} ;;
304
305 --kissat-dir) die "missing argument to $1 (try -h)" ;;
306 --kissat-dir=*) kissat_dir=${1##*=} ;;
307
308 --poly-dir) die "missing argument to $1 (try -h)" ;;
309 --poly-dir=*) poly_dir=${1##*=} ;;
310
311 --symfpu-dir) die "missing argument to $1 (try -h)" ;;
312 --symfpu-dir=*) symfpu_dir=${1##*=} ;;
313
314 --lib-only) lib_only=ON ;;
315
316 -*) die "invalid option '$1' (try -h)";;
317
318 *) case $1 in
319 production) buildtype=Production;;
320 debug) buildtype=Debug;;
321 testing) buildtype=Testing;;
322 competition) buildtype=Competition;;
323 competition-inc) buildtype=Competition; comp_inc=ON;;
324 *) die "invalid build type (try -h)";;
325 esac
326 ;;
327 esac
328 shift
329 done
330
331 #--------------------------------------------------------------------------#
332
333 if [ $werror != default ]; then
334 export CFLAGS=-Werror
335 export CXXFLAGS=-Werror
336 fi
337
338 cmake_opts=""
339
340 [ $buildtype != default ] \
341 && cmake_opts="$cmake_opts -DCMAKE_BUILD_TYPE=$buildtype"
342
343 [ $asan != default ] \
344 && cmake_opts="$cmake_opts -DENABLE_ASAN=$asan"
345 [ $ubsan != default ] \
346 && cmake_opts="$cmake_opts -DENABLE_UBSAN=$ubsan"
347 [ $tsan != default ] \
348 && cmake_opts="$cmake_opts -DENABLE_TSAN=$tsan"
349 [ $assertions != default ] \
350 && cmake_opts="$cmake_opts -DENABLE_ASSERTIONS=$assertions"
351 [ $comp_inc != default ] \
352 && cmake_opts="$cmake_opts -DENABLE_COMP_INC_TRACK=$comp_inc"
353 [ $coverage != default ] \
354 && cmake_opts="$cmake_opts -DENABLE_COVERAGE=$coverage"
355 [ $debug_symbols != default ] \
356 && cmake_opts="$cmake_opts -DENABLE_DEBUG_SYMBOLS=$debug_symbols"
357 [ $debug_context_mm != default ] \
358 && cmake_opts="$cmake_opts -DENABLE_DEBUG_CONTEXT_MM=$debug_context_mm"
359 [ $dumping != default ] \
360 && cmake_opts="$cmake_opts -DENABLE_DUMPING=$dumping"
361 [ $gpl != default ] \
362 && cmake_opts="$cmake_opts -DENABLE_GPL=$gpl"
363 [ $win64 != default ] \
364 && cmake_opts="$cmake_opts -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw64.cmake"
365 [ $arm64 != default ] \
366 && cmake_opts="$cmake_opts -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-aarch64.cmake"
367 [ $ninja != default ] && cmake_opts="$cmake_opts -G Ninja"
368 [ $muzzle != default ] \
369 && cmake_opts="$cmake_opts -DENABLE_MUZZLE=$muzzle"
370 [ $shared != default ] \
371 && cmake_opts="$cmake_opts -DENABLE_SHARED=$shared"
372 [ $static_binary != default ] \
373 && cmake_opts="$cmake_opts -DENABLE_STATIC_BINARY=$static_binary"
374 [ $statistics != default ] \
375 && cmake_opts="$cmake_opts -DENABLE_STATISTICS=$statistics"
376 [ $tracing != default ] \
377 && cmake_opts="$cmake_opts -DENABLE_TRACING=$tracing"
378 [ $unit_testing != default ] \
379 && cmake_opts="$cmake_opts -DENABLE_UNIT_TESTING=$unit_testing"
380 [ $python2 != default ] \
381 && cmake_opts="$cmake_opts -DUSE_PYTHON2=$python2"
382 [ $python_bindings != default ] \
383 && cmake_opts="$cmake_opts -DBUILD_BINDINGS_PYTHON=$python_bindings"
384 [ $java_bindings != default ] \
385 && cmake_opts="$cmake_opts -DBUILD_BINDINGS_JAVA=$java_bindings"
386 [ $valgrind != default ] \
387 && cmake_opts="$cmake_opts -DENABLE_VALGRIND=$valgrind"
388 [ $profiling != default ] \
389 && cmake_opts="$cmake_opts -DENABLE_PROFILING=$profiling"
390 [ $editline != default ] \
391 && cmake_opts="$cmake_opts -DUSE_EDITLINE=$editline"
392 [ $abc != default ] \
393 && cmake_opts="$cmake_opts -DUSE_ABC=$abc"
394 [ $cadical != default ] \
395 && cmake_opts="$cmake_opts -DUSE_CADICAL=$cadical"
396 [ $cln != default ] \
397 && cmake_opts="$cmake_opts -DUSE_CLN=$cln"
398 [ $cryptominisat != default ] \
399 && cmake_opts="$cmake_opts -DUSE_CRYPTOMINISAT=$cryptominisat"
400 [ $glpk != default ] \
401 && cmake_opts="$cmake_opts -DUSE_GLPK=$glpk"
402 [ $kissat != default ] \
403 && cmake_opts="$cmake_opts -DUSE_KISSAT=$kissat"
404 [ $poly != default ] \
405 && cmake_opts="$cmake_opts -DUSE_POLY=$poly"
406 [ $symfpu != default ] \
407 && cmake_opts="$cmake_opts -DUSE_SYMFPU=$symfpu"
408 [ "$abc_dir" != default ] \
409 && cmake_opts="$cmake_opts -DABC_DIR=$abc_dir"
410 [ "$cadical_dir" != default ] \
411 && cmake_opts="$cmake_opts -DCADICAL_DIR=$cadical_dir"
412 [ "$cryptominisat_dir" != default ] \
413 && cmake_opts="$cmake_opts -DCRYPTOMINISAT_DIR=$cryptominisat_dir"
414 [ "$glpk_dir" != default ] \
415 && cmake_opts="$cmake_opts -DGLPK_DIR=$glpk_dir"
416 [ "$gmp_dir" != default ] \
417 && cmake_opts="$cmake_opts -DGMP_DIR=$gmp_dir"
418 [ "$kissat_dir" != default ] \
419 && cmake_opts="$cmake_opts -DKISSAT=$kissat_dir"
420 [ "$poly_dir" != default ] \
421 && cmake_opts="$cmake_opts -DPOLY_DIR=$poly_dir"
422 [ "$symfpu_dir" != default ] \
423 && cmake_opts="$cmake_opts -DSYMFPU_DIR=$symfpu_dir"
424 [ "$lib_only" != default ] \
425 && cmake_opts="$cmake_opts -DBUILD_LIB_ONLY=$lib_only"
426 [ "$install_prefix" != default ] \
427 && cmake_opts="$cmake_opts -DCMAKE_INSTALL_PREFIX=$install_prefix"
428 [ -n "$program_prefix" ] \
429 && cmake_opts="$cmake_opts -DPROGRAM_PREFIX=$program_prefix"
430
431 root_dir=$(pwd)
432
433 # The cmake toolchain can't be changed once it is configured in $build_dir.
434 # Thus, remove $build_dir and create an empty directory.
435 [ $win64 = ON ] && [ -e "$build_dir" ] && rm -r "$build_dir"
436 [ $arm64 = ON ] && [ -e "$build_dir" ] && rm -r "$build_dir"
437 mkdir -p "$build_dir"
438
439 cd "$build_dir"
440
441 [ -e CMakeCache.txt ] && rm CMakeCache.txt
442 build_dir_escaped=$(echo "$build_dir" | sed 's/\//\\\//g')
443 cmake "$root_dir" $cmake_opts 2>&1 | \
444 sed "s/^Now just/Now change to '$build_dir_escaped' and/"