[Unit Tests] Fix bags rewrite test (#7114)
[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 --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
57 Optional Packages:
58 The following flags enable optional packages (disable with --no-<option name>).
59 --cln use CLN instead of GMP
60 --glpk use GLPK simplex solver
61 --abc use the ABC AIG library
62 --cryptominisat use the CryptoMiniSat SAT solver
63 --kissat use the Kissat SAT solver
64 --poly use the LibPoly library [default=yes]
65 --cocoa use the CoCoA library
66 --editline support the editline library
67
68 Optional Path to Optional Packages:
69 --abc-dir=PATH path to top level of ABC source tree
70 --glpk-dir=PATH path to top level of GLPK installation
71 --dep-path=PATH path to a dependency installation dir
72
73 Build limitations:
74 --lib-only only build the library, but not the executable or
75 the parser (default: off)
76
77 CMake Options (Advanced)
78 -DVAR=VALUE manually add CMake options
79
80 EOF
81 exit 0
82 }
83
84 #--------------------------------------------------------------------------#
85
86 die () {
87 echo "*** configure.sh: $*" 1>&2
88 exit 1
89 }
90
91 msg () {
92 echo "[configure.sh] $*"
93 }
94
95 #--------------------------------------------------------------------------#
96
97 [ ! -e src/theory ] && die "$0 not called from CVC4 base directory"
98
99 #--------------------------------------------------------------------------#
100
101 build_dir=build
102 install_prefix=default
103 program_prefix=""
104
105 #--------------------------------------------------------------------------#
106
107 buildtype=default
108
109 abc=default
110 asan=default
111 assertions=default
112 auto_download=default
113 cln=default
114 comp_inc=default
115 coverage=default
116 cryptominisat=default
117 debug_context_mm=default
118 debug_symbols=default
119 docs=default
120 dumping=default
121 glpk=default
122 gpl=default
123 kissat=default
124 poly=ON
125 cocoa=default
126 muzzle=default
127 ninja=default
128 profiling=default
129 python2=default
130 python_bindings=default
131 java_bindings=default
132 editline=default
133 shared=default
134 static_binary=default
135 statistics=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 glpk_dir=default
147
148 lib_only=default
149
150 #--------------------------------------------------------------------------#
151
152 cmake_opts=""
153
154 while [ $# -gt 0 ]
155 do
156 case $1 in
157
158 -h|--help) usage;;
159
160 --abc) abc=ON;;
161 --no-abc) abc=OFF;;
162
163 --asan) asan=ON;;
164 --no-asan) asan=OFF;;
165
166 --ubsan) ubsan=ON;;
167 --no-ubsan) ubsan=OFF;;
168
169 --tsan) tsan=ON;;
170 --no-tsan) tsan=OFF;;
171
172 --werror) werror=ON;;
173
174 --assertions) assertions=ON;;
175 --no-assertions) assertions=OFF;;
176
177 # Best configuration
178 --best)
179 abc=ON
180 cln=ON
181 cryptominisat=ON
182 glpk=ON
183 editline=ON
184 ;;
185
186 --prefix) die "missing argument to $1 (try -h)" ;;
187 --prefix=*)
188 install_prefix=${1##*=}
189 # Check if install_prefix is an absolute path and if not, make it
190 # absolute.
191 case $install_prefix in
192 /*) ;; # absolute path
193 *) install_prefix=$(pwd)/$install_prefix ;; # make absolute path
194 esac
195 ;;
196
197 --program-prefix) die "missing argument to $1 (try -h)" ;;
198 --program-prefix=*) program_prefix=${1##*=} ;;
199
200 --name) die "missing argument to $1 (try -h)" ;;
201 --name=*) build_dir=${1##*=} ;;
202
203 --cln) cln=ON;;
204 --no-cln) cln=OFF;;
205
206 --coverage) coverage=ON;;
207 --no-coverage) coverage=OFF;;
208
209 --cryptominisat) cryptominisat=ON;;
210 --no-cryptominisat) cryptominisat=OFF;;
211
212 --debug-symbols) debug_symbols=ON;;
213 --no-debug-symbols) debug_symbols=OFF;;
214
215 --debug-context-mm) debug_context_mm=ON;;
216 --no-debug-context-mm) debug_context_mm=OFF;;
217
218 --dumping) dumping=ON;;
219 --no-dumping) dumping=OFF;;
220
221 --gpl) gpl=ON;;
222 --no-gpl) gpl=OFF;;
223
224 --kissat) kissat=ON;;
225 --no-kissat) kissat=OFF;;
226
227 --win64) win64=ON;;
228
229 --arm64) arm64=ON;;
230
231 --ninja) ninja=ON;;
232
233 --docs) docs=ON;;
234 --no-docs) docs=OFF;;
235
236 --glpk) glpk=ON;;
237 --no-glpk) glpk=OFF;;
238
239 --poly) poly=ON;;
240 --no-poly) poly=OFF;;
241
242 --cocoa) cocoa=ON;;
243 --no-cocoa) cocoa=OFF;;
244
245 --muzzle) muzzle=ON;;
246 --no-muzzle) muzzle=OFF;;
247
248 --static) shared=OFF; static_binary=ON;;
249 --no-static) shared=ON;;
250
251 --static-binary) static_binary=ON;;
252 --no-static-binary) static_binary=OFF;;
253
254 --auto-download) auto_download=ON;;
255 --no-auto-download) auto_download=OFF;;
256
257 --statistics) statistics=ON;;
258 --no-statistics) statistics=OFF;;
259
260 --tracing) tracing=ON;;
261 --no-tracing) tracing=OFF;;
262
263 --unit-testing) unit_testing=ON;;
264 --no-unit-testing) unit_testing=OFF;;
265
266 --python2) python2=ON;;
267 --no-python2) python2=OFF;;
268
269 --python-bindings) python_bindings=ON;;
270 --no-python-bindings) python_bindings=OFF;;
271
272 --java-bindings) java_bindings=ON;;
273 --no-java-bindings) java_bindings=OFF;;
274
275 --all-bindings)
276 python_bindings=ON
277 java_bindings=ON;;
278
279 --valgrind) valgrind=ON;;
280 --no-valgrind) valgrind=OFF;;
281
282 --profiling) profiling=ON;;
283 --no-profiling) profiling=OFF;;
284
285 --editline) editline=ON;;
286 --no-editline) editline=OFF;;
287
288 --abc-dir) die "missing argument to $1 (try -h)" ;;
289 --abc-dir=*) abc_dir=${1##*=} ;;
290
291 --glpk-dir) die "missing argument to $1 (try -h)" ;;
292 --glpk-dir=*) glpk_dir=${1##*=} ;;
293
294 --dep-path) die "missing argument to $1 (try -h)" ;;
295 --dep-path=*) dep_path="${dep_path};${1##*=}" ;;
296
297 --lib-only) lib_only=ON ;;
298 -D*) cmake_opts="${cmake_opts} $1" ;;
299
300 -*) die "invalid option '$1' (try -h)";;
301
302 *) case $1 in
303 production) buildtype=Production;;
304 debug) buildtype=Debug;;
305 testing) buildtype=Testing;;
306 competition) buildtype=Competition;;
307 competition-inc) buildtype=Competition; comp_inc=ON;;
308 *) die "invalid build type (try -h)";;
309 esac
310 ;;
311 esac
312 shift
313 done
314
315 #--------------------------------------------------------------------------#
316
317 if [ $werror != default ]; then
318 export CFLAGS=-Werror
319 export CXXFLAGS=-Werror
320 fi
321
322 [ $buildtype != default ] \
323 && cmake_opts="$cmake_opts -DCMAKE_BUILD_TYPE=$buildtype"
324
325 [ $asan != default ] \
326 && cmake_opts="$cmake_opts -DENABLE_ASAN=$asan"
327 [ $auto_download != default ] \
328 && cmake_opts="$cmake_opts -DENABLE_AUTO_DOWNLOAD=$auto_download"
329 [ $ubsan != default ] \
330 && cmake_opts="$cmake_opts -DENABLE_UBSAN=$ubsan"
331 [ $tsan != default ] \
332 && cmake_opts="$cmake_opts -DENABLE_TSAN=$tsan"
333 [ $assertions != default ] \
334 && cmake_opts="$cmake_opts -DENABLE_ASSERTIONS=$assertions"
335 [ $comp_inc != default ] \
336 && cmake_opts="$cmake_opts -DENABLE_COMP_INC_TRACK=$comp_inc"
337 [ $coverage != default ] \
338 && cmake_opts="$cmake_opts -DENABLE_COVERAGE=$coverage"
339 [ $debug_symbols != default ] \
340 && cmake_opts="$cmake_opts -DENABLE_DEBUG_SYMBOLS=$debug_symbols"
341 [ $debug_context_mm != default ] \
342 && cmake_opts="$cmake_opts -DENABLE_DEBUG_CONTEXT_MM=$debug_context_mm"
343 [ $dumping != default ] \
344 && cmake_opts="$cmake_opts -DENABLE_DUMPING=$dumping"
345 [ $gpl != default ] \
346 && cmake_opts="$cmake_opts -DENABLE_GPL=$gpl"
347 [ $win64 != default ] \
348 && cmake_opts="$cmake_opts -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw64.cmake"
349 [ $arm64 != default ] \
350 && cmake_opts="$cmake_opts -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-aarch64.cmake"
351 [ $ninja != default ] && cmake_opts="$cmake_opts -G Ninja"
352 [ $muzzle != default ] \
353 && cmake_opts="$cmake_opts -DENABLE_MUZZLE=$muzzle"
354 [ $shared != default ] \
355 && cmake_opts="$cmake_opts -DENABLE_SHARED=$shared"
356 [ $static_binary != default ] \
357 && cmake_opts="$cmake_opts -DENABLE_STATIC_BINARY=$static_binary"
358 [ $statistics != default ] \
359 && cmake_opts="$cmake_opts -DENABLE_STATISTICS=$statistics"
360 [ $tracing != default ] \
361 && cmake_opts="$cmake_opts -DENABLE_TRACING=$tracing"
362 [ $unit_testing != default ] \
363 && cmake_opts="$cmake_opts -DENABLE_UNIT_TESTING=$unit_testing"
364 [ $python2 != default ] \
365 && cmake_opts="$cmake_opts -DUSE_PYTHON2=$python2"
366 [ $docs != default ] \
367 && cmake_opts="$cmake_opts -DBUILD_DOCS=$docs"
368 [ $python_bindings != default ] \
369 && cmake_opts="$cmake_opts -DBUILD_BINDINGS_PYTHON=$python_bindings"
370 [ $java_bindings != default ] \
371 && cmake_opts="$cmake_opts -DBUILD_BINDINGS_JAVA=$java_bindings"
372 [ $valgrind != default ] \
373 && cmake_opts="$cmake_opts -DENABLE_VALGRIND=$valgrind"
374 [ $profiling != default ] \
375 && cmake_opts="$cmake_opts -DENABLE_PROFILING=$profiling"
376 [ $editline != default ] \
377 && cmake_opts="$cmake_opts -DUSE_EDITLINE=$editline"
378 [ $abc != default ] \
379 && cmake_opts="$cmake_opts -DUSE_ABC=$abc"
380 [ $cln != default ] \
381 && cmake_opts="$cmake_opts -DUSE_CLN=$cln"
382 [ $cryptominisat != default ] \
383 && cmake_opts="$cmake_opts -DUSE_CRYPTOMINISAT=$cryptominisat"
384 [ $glpk != default ] \
385 && cmake_opts="$cmake_opts -DUSE_GLPK=$glpk"
386 [ $kissat != default ] \
387 && cmake_opts="$cmake_opts -DUSE_KISSAT=$kissat"
388 [ $poly != default ] \
389 && cmake_opts="$cmake_opts -DUSE_POLY=$poly"
390 [ $cocoa != default ] \
391 && cmake_opts="$cmake_opts -DUSE_COCOA=$cocoa"
392 [ "$abc_dir" != default ] \
393 && cmake_opts="$cmake_opts -DABC_DIR=$abc_dir"
394 [ "$glpk_dir" != default ] \
395 && cmake_opts="$cmake_opts -DGLPK_DIR=$glpk_dir"
396 [ "$dep_path" != default ] \
397 && cmake_opts="$cmake_opts -DCMAKE_PREFIX_PATH=$dep_path"
398 [ "$lib_only" != default ] \
399 && cmake_opts="$cmake_opts -DBUILD_LIB_ONLY=$lib_only"
400 [ "$install_prefix" != default ] \
401 && cmake_opts="$cmake_opts -DCMAKE_INSTALL_PREFIX=$install_prefix"
402 [ -n "$program_prefix" ] \
403 && cmake_opts="$cmake_opts -DPROGRAM_PREFIX=$program_prefix"
404
405 root_dir=$(pwd)
406
407 # The cmake toolchain can't be changed once it is configured in $build_dir.
408 # Thus, remove $build_dir and create an empty directory.
409 [ $win64 = ON ] && [ -e "$build_dir" ] && rm -r "$build_dir"
410 [ $arm64 = ON ] && [ -e "$build_dir" ] && rm -r "$build_dir"
411 mkdir -p "$build_dir"
412
413 cd "$build_dir"
414
415 [ -e CMakeCache.txt ] && rm CMakeCache.txt
416 build_dir_escaped=$(echo "$build_dir" | sed 's/\//\\\//g')
417 cmake "$root_dir" $cmake_opts 2>&1 | \
418 sed "s/^Now just/Now change to '$build_dir_escaped' and/"