forked from trailofbits/cb-multios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·48 lines (38 loc) · 1.19 KB
/
build.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
#!/usr/bin/env bash
set -e
# Root cb-multios directory
DIR=$(cd "$(dirname ${BASH_SOURCE[0]})" && pwd)
TOOLS="$DIR/tools"
# Install necessary python packages
if ! /usr/bin/env python -c "import xlsxwriter; import Crypto" 2>/dev/null; then
echo "Please install required python packages" >&2
echo " $ sudo pip install xlsxwriter pycrypto" >&2
exit 1
fi
echo "Creating build directory"
mkdir -p ${DIR}/build
cd ${DIR}/build
echo "Creating Makefiles"
CMAKE_OPTS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
# Honor CC and CXX environment variables
if [ -x "$CC" ]; then
CMAKE_OPTS="$CMAKE_OPTS -DCMAKE_C_COMPILER=$CC"
CMAKE_OPTS="$CMAKE_OPTS -DCMAKE_ASM_COMPILER=$CC"
fi
if [ -x "$CXX" ]; then
CMAKE_OPTS="$CMAKE_OPTS -DCMAKE_CXX_COMPILER=$CXX"
fi
LINK=${LINK:-SHARED}
case $LINK in
SHARED) CMAKE_OPTS="$CMAKE_OPTS -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF";;
STATIC) CMAKE_OPTS="$CMAKE_OPTS -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON";;
esac
# Prefer ninja over make, if it is available
if which ninja 2>&1 >/dev/null; then
CMAKE_OPTS="-G Ninja $CMAKE_OPTS"
BUILD_FLAGS=
else
BUILD_FLAGS="-- -j$(getconf _NPROCESSORS_ONLN)"
fi
cmake $CMAKE_OPTS ..
cmake --build . $BUILD_FLAGS