1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
#!/usr/bin/env bash
# Boolector: Satisfiablity Modulo Theories (SMT) solver.
#
# Copyright (C) 2007-2021 by the authors listed in the AUTHORS file.
#
# This file is part of Boolector.
# See COPYING for more information on using this software.
#
# This script defines common utility functions used by the contrib/setup-*.sh
# scripts.
die () {
echo "*** error: $*" 1>&2
exit 1
}
[ ! -e src/boolector.c ] && die "$0 not called from Boolector base directory"
DEPS_DIR="$(pwd)/deps"
INSTALL_DIR="${DEPS_DIR}/install"
INSTALL_LIB_DIR="${INSTALL_DIR}/lib"
INSTALL_INCLUDE_DIR="${INSTALL_DIR}/include"
INSTALL_BIN_DIR="${INSTALL_DIR}/bin"
WINDOWS_PATCHES_DIR="$(pwd)/contrib/windows_patches"
MACOS_PATCHES_DIR="$(pwd)/contrib/macos_patches"
if type nproc > /dev/null 2>&1; then
NPROC=$(nproc)
elif [ "$(uname -s)" == "Darwin" ]; then
NPROC=$(sysctl -n hw.physicalcpu)
else
NPROC=2
fi
mkdir -p "${DEPS_DIR}"
mkdir -p "${INSTALL_LIB_DIR}"
mkdir -p "${INSTALL_INCLUDE_DIR}"
mkdir -p "${INSTALL_BIN_DIR}"
function install_lib
{
cp "$1" "${INSTALL_DIR}/lib"
}
function install_include
{
include="$1"
subdir="$2"
if [ -n "$subdir" ]; then
mkdir -p "${INSTALL_INCLUDE_DIR}/$subdir"
fi
cp "$include" "${INSTALL_INCLUDE_DIR}/$subdir"
}
function install_bin
{
cp "$1" "${INSTALL_BIN_DIR}"
}
function is_windows
{
#
# Helper function to check if we're running under Windows, returns false
# otherwise.
#
case "$(uname -s)" in
CYGWIN*|MINGW32*|MINGW64*|MSYS*)
return
;;
esac
false
}
function is_macos
{
case "$(uname -s)" in
Darwin*)
return
;;
esac
false
}
function test_apply_patch
{
#
# This is a function to help apply a patch, only if the patch applies
# cleanly.
#
# If the patch _does not_ apply cleanly, it prints a warning and exits
# (and therefore blocks compilation of the feature)!
#
local component="$1"
local last_patch_date="$2"
if is_windows; then
local patch_set="${WINDOWS_PATCHES_DIR}/${component}_${last_patch_date}.patch"
local os_name="Windows"
else
local patch_set="${MACOS_PATCHES_DIR}/${component}_${last_patch_date}.patch"
local os_name="macOS"
fi
patch -p1 -N --dry-run --silent < "${patch_set}" 2>/dev/null
if [ $? -eq 0 ]; then
#
# Apply patch if the dry-run was successful.
#
patch -p1 -N < "${patch_set}"
else
#
# Otherwise, print an error and bomb-out!
#
echo "##############################################################"
echo "# ***Critical error***"
echo "#"
echo "# Failed to patch ${component} to be ${os_name}-compatible!"
echo "#"
echo "# Please create an issue on GitHub.com:"
echo "#"
echo "# https://github.com/Boolector/boolector/issues"
echo "#"
echo "# Compilation *will not* continue!"
echo "##############################################################"
exit 1
fi
}
function download_github
{
local repo="$1"
local version="$2"
local location="$3"
local tar_args="$4"
local name=$(echo "$repo" | cut -d '/' -f 2)
local archive="$name-$version.tar.gz"
curl -o "$archive" -L "https://github.com/$repo/archive/$version.tar.gz"
rm -rf "${location}"
tar xfvz "$archive" $tar_args
rm "$archive"
mv "$name-$version" "${location}"
}
|