|
| 1 | +#!/bin/bash -u |
| 2 | + |
| 3 | +echo |
| 4 | +echo "Take a look here if Unicorn fails to build:" |
| 5 | +echo " https://github.com/unicorn-engine/unicorn/blob/master/docs/COMPILE-NIX.md" |
| 6 | +echo |
| 7 | +echo "If you're on Ubuntu, you want to do this first:" |
| 8 | +echo " sudo apt-get update" |
| 9 | +echo " sudo apt-get install python-pip build-essential git cmake python-dev libglib2.0-dev" |
| 10 | +echo |
| 11 | +echo "If you're on a Mac, do this first:" |
| 12 | +echo " brew install pkg-config glib cmake" |
| 13 | +echo |
| 14 | +echo "Using ./build as a tmp dir. ^C if that's a bad idea." |
| 15 | +echo |
| 16 | +echo -n "[press enter to continue]" |
| 17 | +read |
| 18 | +echo |
| 19 | + |
| 20 | +cwd=$(pwd) |
| 21 | +build="$cwd/build" |
| 22 | + |
| 23 | +mkdir build &>/dev/null |
| 24 | +set -e |
| 25 | + |
| 26 | +echo "[*] Building Keystone" |
| 27 | +cd "$build" |
| 28 | +git clone https://github.com/keystone-engine/keystone.git |
| 29 | +cd keystone && mkdir build && cd build |
| 30 | +cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DLLVM_TARGETS_TO_BUILD="all" -G "Unix Makefiles" .. && make -j2 |
| 31 | +echo |
| 32 | + |
| 33 | +echo "[*] Building Capstone" |
| 34 | +cd "$build" |
| 35 | +git clone https://github.com/aquynh/capstone.git |
| 36 | +cd capstone && make -j2 |
| 37 | +echo |
| 38 | + |
| 39 | +echo "[*] Building Unicorn" |
| 40 | +cd "$build" |
| 41 | +git clone https://github.com/unicorn-engine/unicorn.git |
| 42 | +cd unicorn && ./make.sh |
| 43 | + |
| 44 | +echo |
| 45 | +echo "[*] Installing projects and Python bindings (using sudo)" |
| 46 | +cd "$build/keystone/build" && sudo make install |
| 47 | +cd "$build/keystone/bindings/python" && sudo make install |
| 48 | + |
| 49 | +cd "$build/capstone" && sudo make install |
| 50 | +cd "$build/capstone/bindings/python" && sudo make install |
| 51 | + |
| 52 | +cd "$build/unicorn" && sudo ./make.sh install |
| 53 | +cd "$build/unicorn/bindings/python" && sudo make install |
| 54 | + |
| 55 | +which ldconfig &>/dev/null && sudo ldconfig |
| 56 | + |
| 57 | +echo |
| 58 | +echo "All done! Don't forget to `sudo pip install coding`, or use a virtualenv if you're hip with that." |
| 59 | +echo |
| 60 | +echo -n "Testing Python import: " |
| 61 | +python -c "import capstone, keystone, unicorn; print 'works.'" |
0 commit comments