1#!/bin/bash
2
3umask 002
4
5if [ "$1" != "--update" ]; then
6    if [ $(tput colors) -ne 256 ]; then
7        echo -n "warning: your terminal doesn't support 256 colors, continue ? [Y/n] "
8        read line
9        if [ "$line" == "n" ]; then
10            exit
11        fi
12    fi
13
14    REQ_EXEC="python3 pip3 c++filt"
15    for EXEC in ${REQ_EXEC}
16    do
17        if [ ! -x "$(command -v $EXEC)" ]
18        then
19            echo "error: unable to find $EXEC, this is required to setup this project"
20            exit
21        fi
22    done
23
24    PYTHON_VERSION=`python3 -c 'import sys; print("%i" % (sys.hexversion<0x03040000))'`
25    if [ $PYTHON_VERSION -ne 0 ]; then
26        echo "error: you need at least python 3.4 to run this project"
27        exit
28    fi
29
30    # Capstone
31    pushd . > /dev/null
32    mkdir -p build
33    cd build
34    CAPSTONE_VERSION="4.0-alpha5"
35    if [ -d capstone_$CAPSTONE_VERSION ]; then
36        cd capstone_$CAPSTONE_VERSION
37        make clean
38    else
39        git clone -b $CAPSTONE_VERSION --depth 1 https://github.com/aquynh/capstone
40        mv capstone capstone_$CAPSTONE_VERSION
41        cd capstone_$CAPSTONE_VERSION
42    fi
43    ./make.sh
44    sudo -H ./make.sh install
45    cd bindings/python/
46    make install3
47    popd > /dev/null
48
49    sudo -H pip3 install -r requirements.txt
50    sudo -H pip3 install future
51fi
52
53python3 setup.py build_ext --inplace
54
55# Or create an alias to run_plasma.py
56sudo -H python3 setup.py install
57