Nguyen Anh Quynh | 64d4083 | 2014-01-17 20:55:21 +0800 | [diff] [blame] | 1 | #! /usr/bin/env bash |
| 2 | |
| 3 | # Capstone Disassembler Engine |
| 4 | # By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> |
| 5 | |
| 6 | # Note: to cross-compile "nix32" on Linux, package gcc-multilib is required. |
| 7 | |
| 8 | function build { |
Nguyen Anh Quynh | af87393 | 2014-01-28 11:14:55 +0800 | [diff] [blame] | 9 | ${MAKE} clean |
Nguyen Anh Quynh | 64d4083 | 2014-01-17 20:55:21 +0800 | [diff] [blame] | 10 | |
| 11 | if [ ${CC}x != x ]; then |
| 12 | ${MAKE} CC=$CC |
| 13 | else |
| 14 | ${MAKE} |
| 15 | fi |
| 16 | } |
| 17 | |
| 18 | function install { |
Nguyen Anh Quynh | 64d4083 | 2014-01-17 20:55:21 +0800 | [diff] [blame] | 19 | if [ ${CC}x != x ]; then |
| 20 | ${MAKE} CC=$CC install |
| 21 | else |
| 22 | ${MAKE} install |
| 23 | fi |
| 24 | } |
| 25 | |
Nguyen Anh Quynh | af87393 | 2014-01-28 11:14:55 +0800 | [diff] [blame] | 26 | MAKE=make |
Nguyen Anh Quynh | d3b3071 | 2014-01-17 21:25:18 +0800 | [diff] [blame] | 27 | if [ "$(uname)" == "SunOS" ]; then |
| 28 | export MAKE=gmake |
| 29 | export INSTALL_BIN=ginstall |
| 30 | export CC=gcc |
| 31 | fi |
| 32 | |
Nguyen Anh Quynh | f63db27 | 2014-01-17 22:12:35 +0800 | [diff] [blame] | 33 | if [[ "$(uname)" == *BSD* ]]; then |
| 34 | export MAKE=gmake |
| 35 | export PREFIX=/usr/local |
| 36 | fi |
| 37 | |
Nguyen Anh Quynh | 64d4083 | 2014-01-17 20:55:21 +0800 | [diff] [blame] | 38 | case "$1" in |
| 39 | "" ) build;; |
| 40 | "default" ) build;; |
| 41 | "install" ) install;; |
Nguyen Anh Quynh | af87393 | 2014-01-28 11:14:55 +0800 | [diff] [blame] | 42 | "uninstall" ) ${MAKE} uninstall;; |
Nguyen Anh Quynh | 64d4083 | 2014-01-17 20:55:21 +0800 | [diff] [blame] | 43 | "nix32" ) CFLAGS=-m32 LDFLAGS=-m32 build;; |
Nguyen Anh Quynh | 64d4083 | 2014-01-17 20:55:21 +0800 | [diff] [blame] | 44 | "cross-win32" ) CROSS=i686-w64-mingw32- build;; |
| 45 | "cross-win64" ) CROSS=x86_64-w64-mingw32- build;; |
| 46 | "cygwin-mingw32" ) CROSS=i686-pc-mingw32- build;; |
| 47 | "cygwin-mingw64" ) CROSS=x86_64-w64-mingw32- build;; |
| 48 | "clang" ) CC=clang build;; |
| 49 | "gcc" ) CC=gcc build;; |
Nguyen Anh Quynh | af87393 | 2014-01-28 11:14:55 +0800 | [diff] [blame] | 50 | * ) echo "Usage: make.sh [nix32|cross-win32|cross-win64|cygwin-mingw32|cygwin-mingw64|clang|gcc|install|uninstall]"; exit 1;; |
Nguyen Anh Quynh | 64d4083 | 2014-01-17 20:55:21 +0800 | [diff] [blame] | 51 | esac |