Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ include_directories(
# Threads
find_package(Threads)

# Fix boost_thread dependency for MacOS
if(APPLE)
set(BOOST_THREAD thread-mt)
else()
set(BOOST_THREAD thread)
endif()

# Boost
find_package(Boost 1.66.0 COMPONENTS filesystem graph system program_options log ${BOOST_THREAD} REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
add_definitions(-DBOOST_LOG_DYN_LINK)

# JSON library
option(JSON_BuildTests OFF)
add_subdirectory(external/json EXCLUDE_FROM_ALL)
Expand All @@ -111,11 +123,6 @@ endif()
add_subdirectory(external/WALi-OpenNWA)
include_directories(external/WALi-OpenNWA/Source/wali/include)

# Boost
find_package(Boost COMPONENTS filesystem graph system program_options log thread REQUIRED)
include_directories(${BOOST_INCLUDE_DIR})
add_definitions(-DBOOST_LOG_DYN_LINK)

# SQL
find_path(SQLITE3_INCLUDE_DIR NAMES sqlite3.h)
find_library(SQLITE3_LIBRARY NAMES sqlite3)
Expand Down Expand Up @@ -203,13 +210,6 @@ llvm_map_components_to_libnames(llvm_libs
# phasar-based binaries
add_subdirectory(tools)

# Fix boost_thread dependency for MacOS
if(APPLE)
set(BOOST_THREAD boost_thread-mt)
else()
set(BOOST_THREAD boost_thread)
endif()

# Workaround: Remove Plugins for MacOS for now
if(APPLE)
set(PHASAR_PLUGINS_LIB)
Expand Down
137 changes: 82 additions & 55 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#!/bin/bash
set -e

readonly PHASAR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
readonly PHASAR_INSTALL_DIR="/usr/local/phasar"
readonly LLVM_INSTALL_DIR="/usr/local/llvm-9"

NUM_THREADS=$(nproc)
LLVM_RELEASE=llvmorg-9.0.0
DO_UNIT_TEST=false


# Parsing command-line-parameters
# See "https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash" as a reference
Expand All @@ -18,6 +24,19 @@ case $key in
shift # past argument
shift # past value
;;
-u|--unittest)
DO_UNIT_TEST=true
shift # past argument
;;
-DBOOST_DIR)
DESIRED_BOOST_DIR="$2"
shift # past argument
shift # past value
;;
-DBOOST_DIR=*)
DESIRED_BOOST_DIR="${key#*=}"
shift # past argument=value
;;
-DBOOST_VERSION)
DESIRED_BOOST_VERSION="$2"
shift # past argument
Expand All @@ -41,79 +60,87 @@ set -- "${POSITIONAL[@]}" # restore positional parameters
echo "installing phasar dependencies..."

sudo apt-get update
sudo apt-get install zlib1g-dev sqlite3 libsqlite3-dev libmysqlcppconn-dev bear python3 doxygen graphviz python python-dev python3-pip python-pip libxml2 libxml2-dev libncurses5-dev libncursesw5-dev swig build-essential g++ cmake libz3-dev libedit-dev python-sphinx libomp-dev libcurl4-openssl-dev -y
sudo apt-get install zlib1g-dev sqlite3 libsqlite3-dev bear python3 doxygen graphviz python python-dev python3-pip python-pip libxml2 libxml2-dev libncurses5-dev libncursesw5-dev swig build-essential g++ cmake libz3-dev libedit-dev python-sphinx libomp-dev libcurl4-openssl-dev -y
sudo pip install Pygments
sudo pip install pyyaml
# installing boost
#wget https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz
#tar xvf boost_1_66_0.tar.gz
#cd boost_1_66_0/
#./bootstrap.sh
#sudo ./b2 install
#cd ..

if [ ! -z ${DESIRED_BOOST_DIR} ]; then
BOOST_PARAMS="-DBOOST_ROOT=${DESIRED_BOOST_DIR}"
else
# New way of installing boost:

# Check whether we have the required boost packages installed

BOOST_VERSION=$(echo -e '#include <boost/version.hpp>\nBOOST_LIB_VERSION' | gcc -s -x c++ -E - 2>/dev/null| grep "^[^#;]" | tr -d '\"')

if [ -z $BOOST_VERSION ] ;then
if [ -z $DESIRED_BOOST_VERSION ] ;then
sudo apt-get install libboost-all-dev -y
else
# DESIRED_BOOST_VERSION in form d.d, i.e. 1.65 (this is the latest version I found in the apt repo)
sudo apt-get install "libboost${DESIRED_BOOST_VERSION}-all-dev" -y
fi
#verify installation
BOOST_VERSION=$(echo -e '#include <boost/version.hpp>\nBOOST_LIB_VERSION' | gcc -s -x c++ -E - 2>/dev/null| grep "^[^#;]" | tr -d '\"')
if [ -z $BOOST_VERSION ] ;then
echo "Failed installing boost $DESIRED_BOOST_VERSION"
exit 1
else
echo "Successfully installed boost v${BOOST_VERSION//_/.}"
fi
else
echo "Already installed boost version ${BOOST_VERSION//_/.}"
DESIRED_BOOST_VERSION=${BOOST_VERSION//_/.}
# install missing packages if necessary
boostlibnames=("libboost-system" "libboost-filesystem"
"libboost-graph" "libboost-program-options"
"libboost-log" "libboost-thread")
additional_boost_libs=()

for boost_lib in ${boostlibnames[@]}; do
dpkg -s "$boost_lib${DESIRED_BOOST_VERSION}" >/dev/null 2>&1 || additional_boost_libs+=("$boost_lib${DESIRED_BOOST_VERSION}")
done
if [ ${#additional_boost_libs[@]} -gt 0 ] ;then
echo "Installing additional ${#additional_boost_libs[@]} boost packages: ${additional_boost_libs[@]}"
sudo apt-get install ${additional_boost_libs[@]} -y
fi
BOOST_VERSION=$(echo -e '#include <boost/version.hpp>\nBOOST_LIB_VERSION' | gcc -s -x c++ -E - 2>/dev/null| grep "^[^#;]" | tr -d '\"')

if [ -z $BOOST_VERSION ] ;then
if [ -z $DESIRED_BOOST_VERSION ] ;then
sudo apt-get install libboost-all-dev -y
else
# DESIRED_BOOST_VERSION in form d.d, i.e. 1.65 (this is the latest version I found in the apt repo)
sudo apt-get install "libboost${DESIRED_BOOST_VERSION}-all-dev" -y
fi
#verify installation
BOOST_VERSION=$(echo -e '#include <boost/version.hpp>\nBOOST_LIB_VERSION' | gcc -s -x c++ -E - 2>/dev/null| grep "^[^#;]" | tr -d '\"')
if [ -z $BOOST_VERSION ] ;then
echo "Failed installing boost $DESIRED_BOOST_VERSION"
exit 1
else
echo "Successfully installed boost v${BOOST_VERSION//_/.}"
fi
else
echo "Already installed boost version ${BOOST_VERSION//_/.}"
DESIRED_BOOST_VERSION=${BOOST_VERSION//_/.}
# install missing packages if necessary
boostlibnames=("libboost-system" "libboost-filesystem"
"libboost-graph" "libboost-program-options"
"libboost-log" "libboost-thread")
additional_boost_libs=()
for boost_lib in ${boostlibnames[@]}; do
dpkg -s "$boost_lib${DESIRED_BOOST_VERSION}" >/dev/null 2>&1 || additional_boost_libs+=("$boost_lib${DESIRED_BOOST_VERSION}")
done
if [ ${#additional_boost_libs[@]} -gt 0 ] ;then
echo "Installing additional ${#additional_boost_libs[@]} boost packages: ${additional_boost_libs[@]}"
sudo apt-get install ${additional_boost_libs[@]} -y
fi
fi
fi



# installing LLVM
./utils/install-llvm.sh $NUM_THREADS . $LLVM_RELEASE
# installing wllvm
tmp_dir=`mktemp -d "llvm-9_build.XXXXXXXX" --tmpdir`
./utils/install-llvm.sh ${NUM_THREADS} ${tmp_dir} ${LLVM_INSTALL_DIR} ${LLVM_RELEASE}
rm -rf ${tmp_dir}
sudo pip3 install wllvm

echo "dependencies successfully installed"
echo "build phasar..."
echo "Building PhASAR..."
${DO_UNIT_TESTS} && echo "with unit tests."

#git submodule init
#git submodule update
git submodule init
git submodule update

export CC=/usr/local/bin/clang
export CXX=/usr/local/bin/clang++
export CC=${LLVM_INSTALL}/bin/clang
export CXX=${LLVM_INSTALL}/bin/clang++

mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
mkdir -p ${PHASAR_DIR}/build
cd ${PHASAR_DIR}/build
cmake -DCMAKE_BUILD_TYPE=Release ${BOOST_PARAMS} -DPHASAR_BUILD_UNITTESTS=${DO_UNIT_TEST} ${PHASAR_DIR}
make -j $NUM_THREADS

if ${DO_UNIT_TEST}; then
echo "Running PhASAR unit tests..."
pushd unittests
for x in `find . -type f -executable -print`; do
pushd ${x%/*} && ./${x##*/} && popd || { echo "Test ${x} failed, aborting."; exit 1; };
done
popd
fi

echo "phasar successfully built"
echo "install phasar..."
sudo make install
sudo cmake -DCMAKE_INSTALL_PREFIX=${PHASAR_INSTALL_DIR} -P cmake_install.cmake

sudo ldconfig
cd ..
echo "phasar successfully installed"
echo "phasar successfully installed to ${PHASAR_INSTALL_DIR}"
3 changes: 2 additions & 1 deletion lib/Controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ else()
)
endif()

find_package(Boost COMPONENTS log REQUIRED)
target_link_libraries(phasar_controller
LINK_PUBLIC
curl
boost_log
${Boost_LIBRARIES}
)

set_target_properties(phasar_controller
Expand Down
4 changes: 2 additions & 2 deletions lib/PhasarClang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ else()
)
endif()

find_package(Boost COMPONENTS log REQUIRED)
target_link_libraries(phasar_clang
LINK_PUBLIC
clangTooling
Expand All @@ -42,8 +43,7 @@ target_link_libraries(phasar_clang
clangLex
clangBasic

boost_log
boost_system
${Boost_LIBRARIES}
)

set_target_properties(phasar_clang
Expand Down
4 changes: 2 additions & 2 deletions lib/PhasarLLVM/DataFlowSolver/WPDS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ else()
)
endif()

find_package(Boost COMPONENTS filesystem REQUIRED)
target_link_libraries(phasar_wpds
LINK_PUBLIC
boost_filesystem
boost_system
${Boost_LIBRARIES}
)

set_target_properties(phasar_wpds
Expand Down
5 changes: 2 additions & 3 deletions lib/PhasarLLVM/Passes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ else()
)
endif()

find_package(Boost COMPONENTS log filesystem REQUIRED)
target_link_libraries(phasar_passes
LINK_PUBLIC
boost_log
boost_filesystem
boost_system
${Boost_LIBRARIES}
)

set_target_properties(phasar_passes
Expand Down
7 changes: 3 additions & 4 deletions lib/PhasarLLVM/Plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ else()
)
endif()


find_package(Boost COMPONENTS log filesystem program_options REQUIRED)
target_link_libraries(phasar_plugins
LINK_PUBLIC
boost_filesystem
boost_log
boost_program_options
boost_system
${Boost_LIBRARIES}
${CMAKE_DL_LIBS}
)

Expand Down
8 changes: 3 additions & 5 deletions lib/PhasarLLVM/Pointer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ else()
)
endif()

find_package(Boost COMPONENTS log filesystem graph REQUIRED)
target_link_libraries(phasar_pointer
LINK_PUBLIC
boost_log
boost_filesystem
boost_graph
boost_system
LINK_PUBLIC
${Boost_LIBRARIES}
)

set_target_properties(phasar_pointer
Expand Down
5 changes: 2 additions & 3 deletions lib/PhasarLLVM/TypeHierarchy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ else()
)
endif()

find_package(Boost COMPONENTS log filesystem graph REQUIRED)
target_link_libraries(phasar_typehierarchy
LINK_PUBLIC
boost_log
boost_filesystem
boost_graph
${Boost_LIBRARIES}
)

set_target_properties(phasar_typehierarchy
Expand Down
4 changes: 2 additions & 2 deletions lib/PhasarLLVM/Utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ else()
)
endif()

find_package(Boost COMPONENTS filesystem REQUIRED)
target_link_libraries(phasar_phasarllvm_utils
LINK_PUBLIC
boost_filesystem
boost_system
${Boost_LIBRARIES}
)

set_target_properties(phasar_phasarllvm_utils
Expand Down
8 changes: 3 additions & 5 deletions lib/PhasarPass/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ endif()

# We specifically link internal phasar libs into phasar_pass so on that the
# llvm user side only has to specify one library.

find_package(Boost COMPONENTS log filesystem graph program_options REQUIRED)
target_link_libraries(phasar_pass
LINK_PUBLIC
${PHASAR_LINK_LIBS}
boost_filesystem
boost_graph
boost_log
boost_program_options
boost_system
${Boost_LIBRARIES}
)

set_target_properties(phasar_pass
Expand Down
3 changes: 2 additions & 1 deletion lib/Utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ else()
)
endif()

find_package(Boost COMPONENTS log REQUIRED)
target_link_libraries(phasar_utils
LINK_PUBLIC
boost_log
${Boost_LIBRARIES}
${CMAKE_DL_LIBS}
)

Expand Down
7 changes: 1 addition & 6 deletions tools/boomerang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ else()
)
endif()

find_package(Boost COMPONENTS log filesystem program_options graph ${BOOST_THREAD} REQUIRED)
target_link_libraries(boomerang
LINK_PUBLIC
phasar_config
Expand All @@ -26,12 +27,6 @@ target_link_libraries(boomerang
phasar_typehierarchy
phasar_phasarllvm_utils
phasar_utils
boost_program_options
boost_filesystem
boost_graph
boost_system
boost_log
${BOOST_THREAD}
${Boost_LIBRARIES}
${CMAKE_DL_LIBS}
${CMAKE_THREAD_LIBS_INIT}
Expand Down
Loading