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