Fix cached free variable identifiers in sygus term database (#4394)
[cvc5.git] / configure.sh
index 98f39779e4ccc29f258b8e2c2921218770cee587..070e2c23025762cab92f67652325f1655c1a6c76 100755 (executable)
@@ -1,6 +1,8 @@
-#!/bin/sh
+#!/bin/bash
 #--------------------------------------------------------------------------#
 
+set -e -o pipefail
+
 usage () {
 cat <<EOF
 Usage: $0 [<build type>] [<option> ...]
@@ -10,36 +12,43 @@ Build types:
   debug
   testing
   competition
+  competition-inc
 
 
 General options;
   -h, --help               display this help and exit
   --prefix=STR             install directory
-  --build-prefix=STR       prefix build directory with given prefix
-  --name=STR               use custom build directory name
-  --best                   turn on dependences known to give best performance
-  --gpl                    permit GPL dependences, if available
+  --program-prefix=STR     prefix of binaries prepended on make install
+  --name=STR               use custom build directory name (optionally: +path)
+  --best                   turn on dependencies known to give best performance
+  --gpl                    permit GPL dependencies, if available
   --win64                  cross-compile for Windows 64 bit
+  --ninja                  use Ninja build system
 
 
 Features:
 The following flags enable optional features (disable with --no-<option name>).
   --static                 build static libraries and binaries [default=no]
+  --static-binary          enable/disable static binaries
   --proofs                 support for proof generation
   --optimized              optimize the build
   --debug-symbols          include debug symbols
   --valgrind               Valgrind instrumentation
   --debug-context-mm       use the debug context memory manager
-  --statistics             do not include statistics
-  --replay                 turn off the replay feature
-  --assertions             turn off assertions
-  --tracing                remove all tracing code
-  --dumping                remove all dumping code
+  --statistics             include statistics
+  --assertions             turn on assertions
+  --tracing                include tracing code
+  --dumping                include dumping code
   --muzzle                 complete silence (no non-result output)
   --coverage               support for gcov coverage testing
   --profiling              support for gprof profiling
   --unit-testing           support for unit testing
-  --python2                prefer using Python 2 (for Python bindings)
+  --python2                prefer using Python 2 (also for Python bindings)
+  --python3                prefer using Python 3 (also for Python bindings)
+  --python-bindings        build Python bindings based on new C++ API
+  --asan                   build with ASan instrumentation
+  --ubsan                  build with UBSan instrumentation
+  --tsan                   build with TSan instrumentation
 
 The following options configure parameterized features.
 
@@ -49,29 +58,27 @@ The following options configure parameterized features.
 Optional Packages:
 The following flags enable optional packages (disable with --no-<option name>).
   --cln                    use CLN instead of GMP
-  --gmp                    use GMP instead of CLN
   --glpk                   use GLPK simplex solver
   --abc                    use the ABC AIG library
   --cadical                use the CaDiCaL SAT solver
-  --cryptominisat          use the CRYPTOMINISAT sat solver
+  --cryptominisat          use the CryptoMiniSat SAT solver
+  --drat2er                use drat2er (required for eager BV proofs)
   --lfsc                   use the LFSC proof checker
-  --symfpu                 use symfpu for floating point solver
-  --portfolio              build the multithreaded portfolio version of CVC4
-                           (pcvc4)
+  --symfpu                 use SymFPU for floating point solver
   --readline               support the readline library
 
 Optional Path to Optional Packages:
-  --abc-dir=PATH           path to top level of abc source tree
+  --abc-dir=PATH           path to top level of ABC source tree
   --antlr-dir=PATH         path to ANTLR C headers and libraries
   --cadical-dir=PATH       path to top level of CaDiCaL source tree
-  --cryptominisat-dir=PATH path to top level of cryptominisat source tree
-  --cxxtest-dir=DIR        path to CxxTest installation
-  --glpk-dir=PATH          path to top level of glpk installation
+  --cryptominisat-dir=PATH path to top level of CryptoMiniSat source tree
+  --drat2er-dir=PATH       path to the top level of the drat2er installation
+  --cxxtest-dir=PATH       path to CxxTest installation
+  --glpk-dir=PATH          path to top level of GLPK installation
   --gmp-dir=PATH           path to top level of GMP installation
-  --lfsc-dir=PATH          path to top level of lfsc source tree
-  --symfpu-dir=PATH        path to top level of symfpu source tree
+  --lfsc-dir=PATH          path to top level of LFSC source tree
+  --symfpu-dir=PATH        path to top level of SymFPU source tree
 
-Report bugs to <cvc4-bugs@cs.stanford.edu>.
 EOF
   exit 0
 }
@@ -93,10 +100,9 @@ msg () {
 
 #--------------------------------------------------------------------------#
 
-build_dir=production
+build_dir=build
 install_prefix=default
-build_prefix=""
-build_name=""
+program_prefix=""
 
 #--------------------------------------------------------------------------#
 
@@ -104,30 +110,36 @@ buildtype=default
 
 abc=default
 asan=default
+ubsan=default
+tsan=default
 assertions=default
 best=default
 cadical=default
 cln=default
+comp_inc=default
 coverage=default
 cryptominisat=default
 debug_symbols=default
 debug_context_mm=default
+drat2er=default
 dumping=default
 gpl=default
 win64=default
+ninja=default
 glpk=default
 lfsc=default
 muzzle=default
 optimized=default
-portfolio=default
 proofs=default
-replay=default
 shared=default
+static_binary=default
 statistics=default
 symfpu=default
 tracing=default
 unit_testing=default
 python2=default
+python3=default
+python_bindings=default
 valgrind=default
 profiling=default
 readline=default
@@ -139,6 +151,8 @@ abc_dir=default
 antlr_dir=default
 cadical_dir=default
 cryptominisat_dir=default
+drat2er_dir=default
+cxxtest_dir=default
 glpk_dir=default
 gmp_dir=default
 lfsc_dir=default
@@ -158,6 +172,12 @@ do
     --asan) asan=ON;;
     --no-asan) asan=OFF;;
 
+    --ubsan) ubsan=ON;;
+    --no-ubsan) ubsan=OFF;;
+
+    --tsan) tsan=ON;;
+    --no-tsan) tsan=OFF;;
+
     --assertions) assertions=ON;;
     --no-assertions) assertions=OFF;;
 
@@ -175,11 +195,11 @@ do
         esac
         ;;
 
-    --build-prefix) die "missing argument to $1 (try -h)" ;;
-    --build-prefix=*) build_prefix=${1##*=} ;;
+    --program-prefix) die "missing argument to $1 (try -h)" ;;
+    --program-prefix=*) program_prefix=${1##*=} ;;
 
     --name) die "missing argument to $1 (try -h)" ;;
-    --name=*) build_name=${1##*=} ;;
+    --name=*) build_dir=${1##*=} ;;
 
     --cadical) cadical=ON;;
     --no-cadical) cadical=OFF;;
@@ -196,8 +216,11 @@ do
     --debug-symbols) debug_symbols=ON;;
     --no-debug-symbols) debug_symbols=OFF;;
 
-    --debug-context-memory-manager) debug_context_mm=ON;;
-    --no-debug-context-memory-manager) debug_context_mm=OFF;;
+    --debug-context-mm) debug_context_mm=ON;;
+    --no-debug-context-mm) debug_context_mm=OFF;;
+
+    --drat2er) drat2er=ON;;
+    --no-drat2er) drat2er=OFF;;
 
     --dumping) dumping=ON;;
     --no-dumping) dumping=OFF;;
@@ -208,6 +231,8 @@ do
     --win64) win64=ON;;
     --no-win64) win64=OFF;;
 
+    --ninja) ninja=ON;;
+
     --glpk) glpk=ON;;
     --no-glpk) glpk=OFF;;
 
@@ -220,18 +245,15 @@ do
     --optimized) optimized=ON;;
     --no-optimized) optimized=OFF;;
 
-    --portfolio) portfolio=ON;;
-    --no-portfolio) portfolio=OFF;;
-
     --proofs) proofs=ON;;
     --no-proofs) proofs=OFF;;
 
-    --replay) replay=ON;;
-    --no-replay) replay=OFF;;
-
-    --static) shared=OFF;;
+    --static) shared=OFF; static_binary=ON;;
     --no-static) shared=ON;;
 
+    --static-binary) static_binary=ON;;
+    --no-static-binary) static_binary=OFF;;
+
     --statistics) statistics=ON;;
     --no-statistics) statistics=OFF;;
 
@@ -247,6 +269,12 @@ do
     --python2) python2=ON;;
     --no-python2) python2=OFF;;
 
+    --python3) python3=ON;;
+    --no-python3) python3=OFF;;
+
+    --python-bindings) python_bindings=ON;;
+    --no-python-bindings) python_bindings=OFF;;
+
     --valgrind) valgrind=ON;;
     --no-valgrind) valgrind=OFF;;
 
@@ -285,6 +313,12 @@ do
     --cryptominisat-dir) die "missing argument to $1 (try -h)" ;;
     --cryptominisat-dir=*) cryptominisat_dir=${1##*=} ;;
 
+    --cxxtest-dir) die "missing argument to $1 (try -h)" ;;
+    --cxxtest-dir=*) cxxtest_dir=${1##*=} ;;
+
+    --drat2er-dir) die "missing argument to $1 (try -h)" ;;
+    --drat2er-dir=*) drat2er_dir=${1##*=} ;;
+
     --glpk-dir) die "missing argument to $1 (try -h)" ;;
     --glpk-dir=*) glpk_dir=${1##*=} ;;
 
@@ -300,11 +334,12 @@ do
     -*) die "invalid option '$1' (try -h)";;
 
     *) case $1 in
-         production)  buildtype=Production; build_dir=production;;
-         debug)       buildtype=Debug; build_dir=debug;;
-         testing)     buildtype=Testing; build_dir=testing;;
-         competition) buildtype=Competition; build_dir=competition;;
-         *)           die "invalid build type (try -h)";;
+         production)      buildtype=Production;;
+         debug)           buildtype=Debug;;
+         testing)         buildtype=Testing;;
+         competition)     buildtype=Competition;;
+         competition-inc) buildtype=Competition; comp_inc=ON;;
+         *)               die "invalid build type (try -h)";;
        esac
        ;;
   esac
@@ -319,97 +354,79 @@ cmake_opts=""
   && cmake_opts="$cmake_opts -DCMAKE_BUILD_TYPE=$buildtype"
 
 [ $asan != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_ASAN=$asan" \
-  && [ $asan = ON ] && build_dir="$build_dir-asan"
+  && cmake_opts="$cmake_opts -DENABLE_ASAN=$asan"
+[ $ubsan != default ] \
+  && cmake_opts="$cmake_opts -DENABLE_UBSAN=$ubsan"
+[ $tsan != default ] \
+  && cmake_opts="$cmake_opts -DENABLE_TSAN=$tsan"
 [ $assertions != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_ASSERTIONS=$assertions" \
-  && [ $assertions = ON ] && build_dir="$build_dir-assertions"
+  && cmake_opts="$cmake_opts -DENABLE_ASSERTIONS=$assertions"
 [ $best != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_BEST=$best" \
-  && [ $best = ON ] && build_dir="$build_dir-best"
+  && cmake_opts="$cmake_opts -DENABLE_BEST=$best"
+[ $comp_inc != default ] \
+  && cmake_opts="$cmake_opts -DENABLE_COMP_INC_TRACK=$comp_inc"
 [ $coverage != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_COVERAGE=$coverage" \
-  && [ $coverage = ON ] && build_dir="$build_dir-coverage"
+  && cmake_opts="$cmake_opts -DENABLE_COVERAGE=$coverage"
 [ $debug_symbols != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_DEBUG_SYMBOLS=$debug_symbols" \
-  && [ $debug_symbols = ON ] && build_dir="$build_dir-debug_symbols"
+  && cmake_opts="$cmake_opts -DENABLE_DEBUG_SYMBOLS=$debug_symbols"
 [ $debug_context_mm != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_DEBUG_CONTEXT_MM=$debug_context_mm" \
-  && [ $debug_context_mm = ON ] &&  build_dir="$build_dir-debug_context_mm"
+  && cmake_opts="$cmake_opts -DENABLE_DEBUG_CONTEXT_MM=$debug_context_mm"
 [ $dumping != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_DUMPING=$dumping" \
-  && [ $dumping = ON ] &&  build_dir="$build_dir-dumping"
+  && cmake_opts="$cmake_opts -DENABLE_DUMPING=$dumping"
 [ $gpl != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_GPL=$gpl" \
-  && [ $gpl = ON ] &&  build_dir="$build_dir-gpl"
+  && cmake_opts="$cmake_opts -DENABLE_GPL=$gpl"
 [ $win64 != default ] \
-  && cmake_opts="$cmake_opts -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw64.cmake" \
-  && [ $win64 = ON ] &&  build_dir="$build_dir-win64"
+  && cmake_opts="$cmake_opts -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw64.cmake"
+[ $ninja != default ] && cmake_opts="$cmake_opts -G Ninja"
 [ $muzzle != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_MUZZLE=$muzzle" \
-  && [ $muzzle = ON ] &&  build_dir="$build_dir-muzzle"
+  && cmake_opts="$cmake_opts -DENABLE_MUZZLE=$muzzle"
 [ $optimized != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_OPTIMIZED=$optimized" \
-  && [ $optimized = ON ] &&  build_dir="$build_dir-optimized"
-[ $portfolio != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_PORTFOLIO=$portfolio" \
-  && [ $portfolio = ON ] &&  build_dir="$build_dir-portfolio"
+  && cmake_opts="$cmake_opts -DENABLE_OPTIMIZED=$optimized"
 [ $proofs != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_PROOFS=$proofs" \
-  && [ $proofs = ON ] &&  build_dir="$build_dir-proofs"
-[ $replay != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_REPLAY=$replay" \
-  && [ $replay = ON ] &&  build_dir="$build_dir-replay"
+  && cmake_opts="$cmake_opts -DENABLE_PROOFS=$proofs"
 [ $shared != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_SHARED=$shared" \
-  && [ $shared = OFF ] &&  build_dir="$build_dir-static"
+  && cmake_opts="$cmake_opts -DENABLE_SHARED=$shared"
+[ $static_binary != default ] \
+  && cmake_opts="$cmake_opts -DENABLE_STATIC_BINARY=$static_binary"
 [ $statistics != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_STATISTICS=$statistics" \
-  && [ $statistics = ON ] && build_dir="$build_dir-stastitics"
+  && cmake_opts="$cmake_opts -DENABLE_STATISTICS=$statistics"
 [ $tracing != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_TRACING=$tracing" \
-  && [ $tracing = ON ] && build_dir="$build_dir-tracing"
+  && cmake_opts="$cmake_opts -DENABLE_TRACING=$tracing"
 [ $unit_testing != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_UNIT_TESTING=$unit_testing" \
-  && [ $unit_testing = ON ] && build_dir="$build_dir-unit_testing"
+  && cmake_opts="$cmake_opts -DENABLE_UNIT_TESTING=$unit_testing"
 [ $python2 != default ] \
-  && cmake_opts="$cmake_opts -DUSE_PYTHON2=$python2" \
-  && [ $python2 = ON ] && build_dir="$build_dir-python2"
+  && cmake_opts="$cmake_opts -DUSE_PYTHON2=$python2"
+[ $python3 != default ] \
+  && cmake_opts="$cmake_opts -DUSE_PYTHON3=$python3"
+[ $python_bindings != default ] \
+  && cmake_opts="$cmake_opts -DBUILD_BINDINGS_PYTHON=$python_bindings"
 [ $valgrind != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_VALGRIND=$valgrind" \
-  && [ $valgrind = ON ] && build_dir="$build_dir-valgrind"
+  && cmake_opts="$cmake_opts -DENABLE_VALGRIND=$valgrind"
 [ $profiling != default ] \
-  && cmake_opts="$cmake_opts -DENABLE_PROFILING=$profiling" \
-  && [ $profiling = ON ] && build_dir="$build_dir-profiling"
+  && cmake_opts="$cmake_opts -DENABLE_PROFILING=$profiling"
 [ $readline != default ] \
-  && cmake_opts="$cmake_opts -DUSE_READLINE=$readline" \
-  && [ $readline = ON ] && build_dir="$build_dir-readline"
+  && cmake_opts="$cmake_opts -DUSE_READLINE=$readline"
 [ $abc != default ] \
-  && cmake_opts="$cmake_opts -DUSE_ABC=$abc" \
-  && [ $abc = ON ] && build_dir="$build_dir-abc"
+  && cmake_opts="$cmake_opts -DUSE_ABC=$abc"
 [ $cadical != default ] \
-  && cmake_opts="$cmake_opts -DUSE_CADICAL=$cadical" \
-  && [ $cadical = ON ] && build_dir="$build_dir-cadical"
+  && cmake_opts="$cmake_opts -DUSE_CADICAL=$cadical"
 [ $cln != default ] \
-  && cmake_opts="$cmake_opts -DUSE_CLN=$cln" \
-  && [ $cln = ON ] && build_dir="$build_dir-cln"
+  && cmake_opts="$cmake_opts -DUSE_CLN=$cln"
 [ $cryptominisat != default ] \
-  && cmake_opts="$cmake_opts -DUSE_CRYPTOMINISAT=$cryptominisat" \
-  && [ $cryptominisat = ON ] && build_dir="$build_dir-cryptominisat"
+  && cmake_opts="$cmake_opts -DUSE_CRYPTOMINISAT=$cryptominisat"
+[ $drat2er != default ] \
+  && cmake_opts="$cmake_opts -DUSE_DRAT2ER=$drat2er"
 [ $glpk != default ] \
-  && cmake_opts="$cmake_opts -DUSE_GLPK=$glpk" \
-  && [ $glpk = ON ] && build_dir="$build_dir-glpk"
+  && cmake_opts="$cmake_opts -DUSE_GLPK=$glpk"
 [ $lfsc != default ] \
-  && cmake_opts="$cmake_opts -DUSE_LFSC=$lfsc" \
-  && [ $lfsc = ON ] && build_dir="$build_dir-lfsc"
+  && cmake_opts="$cmake_opts -DUSE_LFSC=$lfsc"
 [ $symfpu != default ] \
-  && cmake_opts="$cmake_opts -DUSE_SYMFPU=$symfpu" \
-  && [ $symfpu = ON ] && build_dir="$build_dir-symfpu"
+  && cmake_opts="$cmake_opts -DUSE_SYMFPU=$symfpu"
 
 [ $language_bindings_java != default ] \
-  && cmake_opts="$cmake_opts -DBUILD_BINDINGS_JAVA=$language_bindings_java"
+  && cmake_opts="$cmake_opts -DBUILD_SWIG_BINDINGS_JAVA=$language_bindings_java"
 [ $language_bindings_python != default ] \
-  && cmake_opts="$cmake_opts -DBUILD_BINDINGS_PYTHON=$language_bindings_python"
+  && cmake_opts="$cmake_opts -DBUILD_SWIG_BINDINGS_PYTHON=$language_bindings_python"
 
 [ "$abc_dir" != default ] \
   && cmake_opts="$cmake_opts -DABC_DIR=$abc_dir"
@@ -419,6 +436,10 @@ cmake_opts=""
   && cmake_opts="$cmake_opts -DCADICAL_DIR=$cadical_dir"
 [ "$cryptominisat_dir" != default ] \
   && cmake_opts="$cmake_opts -DCRYPTOMINISAT_DIR=$cryptominisat_dir"
+[ "$cxxtest_dir" != default ] \
+  && cmake_opts="$cmake_opts -DCXXTEST_DIR=$cxxtest_dir"
+[ "$drat2er_dir" != default ] \
+  && cmake_opts="$cmake_opts -DDRAT2ER_DIR=$drat2er_dir"
 [ "$glpk_dir" != default ] \
   && cmake_opts="$cmake_opts -DGLPK_DIR=$glpk_dir"
 [ "$gmp_dir" != default ] \
@@ -429,38 +450,17 @@ cmake_opts=""
   && cmake_opts="$cmake_opts -DSYMFPU_DIR=$symfpu_dir"
 [ "$install_prefix" != default ] \
   && cmake_opts="$cmake_opts -DCMAKE_INSTALL_PREFIX=$install_prefix"
+[ -n "$program_prefix" ] \
+  && cmake_opts="$cmake_opts -DPROGRAM_PREFIX=$program_prefix"
 
 root_dir=$(pwd)
 
-if [ -n "$build_name" ]; then
-  # If a build name is specified just create directory 'build_name' for the
-  # current build.
-  build_dir=$build_name
-
-  # The cmake toolchain can't be changed once it is configured in $build_dir.
-  # Thus, remove $build_dir and create an empty directory.
-  [ $win64 = ON ] && [ -e "$build_dir" ] && rm -r "$build_dir"
-  mkdir -p "$build_name"
-else
-  default_builds_dir="cmake-builds"
-  current_build_dir="$default_builds_dir/build"
-
-  # If no build name is specified create 'cmake-builds' directory and create
-  # the current build directory. Set symlink 'cmake-builds/build/' to current
-  # build.
-  build_dir="$default_builds_dir/$build_prefix$build_dir"
-
-  # The cmake toolchain can't be changed once it is configured in $build_dir.
-  # Thus, remove $build_dir and create an empty directory.
-  [ $win64 = ON ] && [ -e "$build_dir" ] && rm -r "$build_dir"
-
-  # Create build directory and symlink to it
-  mkdir -p "$build_dir"
-  [ -L $current_build_dir ] && rm "$current_build_dir"
-  ln -s "$root_dir/$build_dir" "$current_build_dir"
-fi
-
-cd "$build_dir" || exit 1
+# The cmake toolchain can't be changed once it is configured in $build_dir.
+# Thus, remove $build_dir and create an empty directory.
+[ $win64 = ON ] && [ -e "$build_dir" ] && rm -r "$build_dir"
+mkdir -p "$build_dir"
+
+cd "$build_dir"
 
 [ -e CMakeCache.txt ] && rm CMakeCache.txt
 build_dir_escaped=$(echo "$build_dir" | sed 's/\//\\\//g')