11#! /bin/bash
22set -e
33
4+ readonly PHASAR_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " > /dev/null 2>&1 && pwd ) "
5+ readonly PHASAR_INSTALL_DIR=" /usr/local/phasar"
6+ readonly LLVM_INSTALL_DIR=" /usr/local/llvm-9"
7+
48NUM_THREADS=$( nproc)
59LLVM_RELEASE=llvmorg-9.0.0
10+ DO_UNIT_TEST=false
11+
612
713# Parsing command-line-parameters
814# See "https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash" as a reference
@@ -18,6 +24,19 @@ case $key in
1824 shift # past argument
1925 shift # past value
2026 ;;
27+ -u|--unittest)
28+ DO_UNIT_TEST=true
29+ shift # past argument
30+ ;;
31+ -DBOOST_DIR)
32+ DESIRED_BOOST_DIR=" $2 "
33+ shift # past argument
34+ shift # past value
35+ ;;
36+ -DBOOST_DIR=* )
37+ DESIRED_BOOST_DIR=" ${key#* =} "
38+ shift # past argument=value
39+ ;;
2140 -DBOOST_VERSION)
2241 DESIRED_BOOST_VERSION=" $2 "
2342 shift # past argument
@@ -41,79 +60,87 @@ set -- "${POSITIONAL[@]}" # restore positional parameters
4160echo " installing phasar dependencies..."
4261
4362sudo apt-get update
44- 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
63+ 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
4564sudo pip install Pygments
4665sudo pip install pyyaml
47- # installing boost
48- # wget https://dl.bintray.com/boostorg/release/1.66.0/source/boost_1_66_0.tar.gz
49- # tar xvf boost_1_66_0.tar.gz
50- # cd boost_1_66_0/
51- # ./bootstrap.sh
52- # sudo ./b2 install
53- # cd ..
5466
67+ if [ ! -z ${DESIRED_BOOST_DIR} ]; then
68+ BOOST_PARAMS=" -DBOOST_ROOT=${DESIRED_BOOST_DIR} "
69+ else
5570# New way of installing boost:
56-
5771# Check whether we have the required boost packages installed
58-
59- BOOST_VERSION= $( echo -e ' #include <boost/version.hpp>\nBOOST_LIB_VERSION ' | gcc -s -x c++ -E - 2> /dev/null | grep " ^[^#;] " | tr -d ' \" ' )
60-
61- if [ -z $BOOST_VERSION ] ; then
62- if [ -z $DESIRED_BOOST_VERSION ] ; then
63- sudo apt-get install libboost-all-dev -y
64- else
65- # DESIRED_BOOST_VERSION in form d.d, i.e. 1.65 (this is the latest version I found in the apt repo)
66- sudo apt-get install " libboost ${DESIRED_BOOST_VERSION} -all-dev " -y
67- fi
68- # verify installation
69- BOOST_VERSION= $( echo -e ' #include <boost/version.hpp>\nBOOST_LIB_VERSION ' | gcc -s -x c++ -E - 2> /dev/null | grep " ^[^#;] " | tr -d ' \" ' )
70- if [ -z $BOOST_VERSION ] ; then
71- echo " Failed installing boost $DESIRED_BOOST_VERSION "
72- exit 1
73- else
74- echo " Successfully installed boost v ${BOOST_VERSION // _ / .} "
75- fi
76- else
77- echo " Already installed boost version ${BOOST_VERSION// _/ .} "
78- DESIRED_BOOST_VERSION= ${BOOST_VERSION // _ / .}
79- # install missing packages if necessary
80- boostlibnames=( " libboost-system " " libboost-filesystem "
81- " libboost-graph " " libboost-program-options "
82- " libboost-log " " libboost-thread " )
83- additional_boost_libs=()
84-
85- for boost_lib in ${boostlibnames[@]} ; do
86- dpkg -s " $boost_lib ${DESIRED_BOOST_VERSION} " > /dev/null 2>&1 || additional_boost_libs+=( " $boost_lib ${DESIRED_BOOST_VERSION} " )
87- done
88- if [ ${# additional_boost_libs[@]} -gt 0 ] ; then
89- echo " Installing additional ${# additional_boost_libs[@]} boost packages: ${additional_boost_libs[@]} "
90- sudo apt-get install ${additional_boost_libs[@]} -y
91- fi
72+ BOOST_VERSION= $( echo -e ' #include <boost/version.hpp>\nBOOST_LIB_VERSION ' | gcc -s -x c++ -E - 2> /dev/null | grep " ^[^#;] " | tr -d ' \" ' )
73+
74+ if [ -z $BOOST_VERSION ] ; then
75+ if [ -z $DESIRED_BOOST_VERSION ] ; then
76+ sudo apt-get install libboost-all-dev -y
77+ else
78+ # DESIRED_BOOST_VERSION in form d.d, i.e. 1.65 (this is the latest version I found in the apt repo)
79+ sudo apt-get install " libboost ${DESIRED_BOOST_VERSION} -all-dev " -y
80+ fi
81+ # verify installation
82+ BOOST_VERSION= $( echo -e ' #include <boost/version.hpp>\nBOOST_LIB_VERSION ' | gcc -s -x c++ -E - 2> /dev/null | grep " ^[^#;] " | tr -d ' \" ' )
83+ if [ -z $BOOST_VERSION ] ; then
84+ echo " Failed installing boost $DESIRED_BOOST_VERSION "
85+ exit 1
86+ else
87+ echo " Successfully installed boost v ${BOOST_VERSION // _ / .} "
88+ fi
89+ else
90+ echo " Already installed boost version ${BOOST_VERSION // _ / .} "
91+ DESIRED_BOOST_VERSION= ${BOOST_VERSION// _/ .}
92+ # install missing packages if necessary
93+ boostlibnames=( " libboost-system " " libboost-filesystem "
94+ " libboost-graph " " libboost-program-options "
95+ " libboost-log " " libboost-thread " )
96+ additional_boost_libs=( )
97+
98+ for boost_lib in ${boostlibnames[@]} ; do
99+ dpkg -s " $boost_lib ${DESIRED_BOOST_VERSION} " > /dev/null 2>&1 || additional_boost_libs+=( " $boost_lib ${DESIRED_BOOST_VERSION} " )
100+ done
101+ if [ ${ # additional_boost_libs[@]} -gt 0 ] ; then
102+ echo " Installing additional ${# additional_boost_libs[@]} boost packages: ${additional_boost_libs[@]} "
103+ sudo apt-get install ${additional_boost_libs[@]} -y
104+ fi
105+ fi
92106fi
93107
94108
95109
96110# installing LLVM
97- ./utils/install-llvm.sh $NUM_THREADS . $LLVM_RELEASE
98- # installing wllvm
111+ tmp_dir=` mktemp -d " llvm-9_build.XXXXXXXX" --tmpdir`
112+ ./utils/install-llvm.sh ${NUM_THREADS} ${tmp_dir} ${LLVM_INSTALL_DIR} ${LLVM_RELEASE}
113+ rm -rf ${tmp_dir}
99114sudo pip3 install wllvm
100115
101116echo " dependencies successfully installed"
102- echo " build phasar..."
117+ echo " Building PhASAR..."
118+ ${DO_UNIT_TESTS} && echo " with unit tests."
103119
104- # git submodule init
105- # git submodule update
120+ git submodule init
121+ git submodule update
106122
107- export CC=/usr/local /bin/clang
108- export CXX=/usr/local /bin/clang++
123+ export CC=${LLVM_INSTALL} /bin/clang
124+ export CXX=${LLVM_INSTALL} /bin/clang++
109125
110- mkdir -p build
111- cd build
112- cmake -DCMAKE_BUILD_TYPE=Release ..
126+ mkdir -p ${PHASAR_DIR} / build
127+ cd ${PHASAR_DIR} / build
128+ cmake -DCMAKE_BUILD_TYPE=Release ${BOOST_PARAMS} -DPHASAR_BUILD_UNITTESTS= ${DO_UNIT_TEST} ${PHASAR_DIR}
113129make -j $NUM_THREADS
130+
131+ if ${DO_UNIT_TEST} ; then
132+ echo " Running PhASAR unit tests..."
133+ pushd unittests
134+ for x in ` find . -type f -executable -print` ; do
135+ pushd ${x%/* } && ./${x##*/ } && popd || { echo " Test ${x} failed, aborting." ; exit 1; };
136+ done
137+ popd
138+ fi
139+
114140echo " phasar successfully built"
115141echo " install phasar..."
116- sudo make install
142+ sudo cmake -DCMAKE_INSTALL_PREFIX=${PHASAR_INSTALL_DIR} -P cmake_install.cmake
143+
117144sudo ldconfig
118145cd ..
119- echo " phasar successfully installed"
146+ echo " phasar successfully installed to ${PHASAR_INSTALL_DIR} "
0 commit comments