-
Notifications
You must be signed in to change notification settings - Fork 99
/
install_cbmc.sh
executable file
·52 lines (39 loc) · 1.17 KB
/
install_cbmc.sh
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
#!/bin/bash
# Copyright Kani Contributors
# SPDX-License-Identifier: Apache-2.0 OR MIT
set -eu
# Source kani-dependencies to get CBMC_VERSION
source kani-dependencies
if [ -z "${CBMC_VERSION:-}" ]; then
echo "$0: Error: CBMC_VERSION is not specified"
exit 1
fi
UBUNTU_VERSION=$(lsb_release -rs)
MAJOR=${UBUNTU_VERSION%.*}
if [[ "${MAJOR}" -ge "20" ]] && [[ $(dpkg --print-architecture) = "amd64" ]]
then
FILE="ubuntu-${UBUNTU_VERSION}-cbmc-${CBMC_VERSION}-Linux.deb"
URL="https://github.com/diffblue/cbmc/releases/download/cbmc-${CBMC_VERSION}/$FILE"
set -x
wget -O "$FILE" "$URL"
sudo dpkg -i "$FILE"
cbmc --version
rm $FILE
exit 0
fi
# There are no binaries for Ubuntu before 20.04 or for non-x86_64, so build from source
WORK_DIR=$(mktemp -d)
git clone \
--branch cbmc-${CBMC_VERSION} --depth 1 \
https://github.com/diffblue/cbmc \
"${WORK_DIR}"
pushd "${WORK_DIR}"
mkdir build
git submodule update --init
cmake -S . -Bbuild -DWITH_JBMC=OFF -Dsat_impl="minisat2;cadical" \
-DBUILD_SHARED_LIBS=OFF -DCMAKE_EXE_LINKER_FLAGS=-static
make -C build -j$(nproc)
cpack -G DEB --config build/CPackConfig.cmake
sudo dpkg -i ./cbmc-*.deb
popd
rm -rf "${WORK_DIR}"