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