blob: 0fb52dac15c2d05b3d24cd8c5a94a93ba6a338b8 [file] [log] [blame]
Nguyen Anh Quynh64d40832014-01-17 20:55:21 +08001#! /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
8function build {
Nguyen Anh Quynhaf873932014-01-28 11:14:55 +08009 ${MAKE} clean
Nguyen Anh Quynh64d40832014-01-17 20:55:21 +080010
11 if [ ${CC}x != x ]; then
12 ${MAKE} CC=$CC
13 else
14 ${MAKE}
15 fi
16}
17
18function install {
Nguyen Anh Quynh64d40832014-01-17 20:55:21 +080019 if [ ${CC}x != x ]; then
20 ${MAKE} CC=$CC install
21 else
22 ${MAKE} install
23 fi
24}
25
Nguyen Anh Quynhaf873932014-01-28 11:14:55 +080026MAKE=make
Nguyen Anh Quynhd3b30712014-01-17 21:25:18 +080027if [ "$(uname)" == "SunOS" ]; then
28export MAKE=gmake
29export INSTALL_BIN=ginstall
30export CC=gcc
31fi
32
Nguyen Anh Quynhf63db272014-01-17 22:12:35 +080033if [[ "$(uname)" == *BSD* ]]; then
34export MAKE=gmake
35export PREFIX=/usr/local
36fi
37
Nguyen Anh Quynh64d40832014-01-17 20:55:21 +080038case "$1" in
39 "" ) build;;
40 "default" ) build;;
41 "install" ) install;;
Nguyen Anh Quynhaf873932014-01-28 11:14:55 +080042 "uninstall" ) ${MAKE} uninstall;;
Nguyen Anh Quynh64d40832014-01-17 20:55:21 +080043 "nix32" ) CFLAGS=-m32 LDFLAGS=-m32 build;;
Nguyen Anh Quynh64d40832014-01-17 20:55:21 +080044 "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 Quynhaf873932014-01-28 11:14:55 +080050 * ) echo "Usage: make.sh [nix32|cross-win32|cross-win64|cygwin-mingw32|cygwin-mingw64|clang|gcc|install|uninstall]"; exit 1;;
Nguyen Anh Quynh64d40832014-01-17 20:55:21 +080051esac