Oliver Pinter | 22062e0 | 2014-01-16 09:31:13 +0100 | [diff] [blame] | 1 | #! /usr/bin/env bash |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 2 | |
| 3 | # Capstone Disassembler Engine |
| 4 | # By Nguyen Anh Quynh <aquynh@gmail.com>, 2013> |
| 5 | |
Nguyen Anh Quynh | b8394a4 | 2013-11-29 10:26:43 +0800 | [diff] [blame] | 6 | # Note: to cross-compile "nix32" on Linux, package gcc-multilib is required. |
| 7 | |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 8 | function build { |
Oliver Pinter | 22062e0 | 2014-01-16 09:31:13 +0100 | [diff] [blame] | 9 | if [ ${MAKE}x = x ]; then |
| 10 | MAKE=make |
| 11 | fi |
| 12 | |
| 13 | CROSS= ${MAKE} clean |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 14 | |
| 15 | if [ ${CC}x != x ]; then |
Oliver Pinter | 22062e0 | 2014-01-16 09:31:13 +0100 | [diff] [blame] | 16 | ${MAKE} CC=$CC |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 17 | else |
Oliver Pinter | 22062e0 | 2014-01-16 09:31:13 +0100 | [diff] [blame] | 18 | ${MAKE} |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 19 | fi |
| 20 | } |
| 21 | |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 22 | case "$1" in |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 23 | "" ) build;; |
Nguyen Anh Quynh | 79654d1 | 2014-01-08 10:36:59 +0800 | [diff] [blame] | 24 | "default" ) build;; |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 25 | "nix32" ) CFLAGS=-m32 LDFLAGS=-m32 build;; |
Oliver Pinter | 22062e0 | 2014-01-16 09:31:13 +0100 | [diff] [blame] | 26 | "bsd") MAKE=gmake PREFIX=/usr/local build;; |
Daniel Godas-Lopez | cf05e11 | 2013-11-28 18:23:39 +0000 | [diff] [blame] | 27 | "clang" ) CC=clang build;; |
| 28 | "cross-win32" ) CROSS=i686-w64-mingw32- build;; |
| 29 | "cross-win64" ) CROSS=x86_64-w64-mingw32- build;; |
| 30 | "cygwin-mingw32" ) CROSS=i686-pc-mingw32- build;; |
| 31 | "cygwin-mingw64" ) CROSS=x86_64-w64-mingw32- build;; |
Oliver Pinter | 22062e0 | 2014-01-16 09:31:13 +0100 | [diff] [blame] | 32 | "gcc") CC=gcc build;; |
| 33 | * ) echo "Usage: compile.sh [nix32|bsd|clang|cross-win32|cross-win64|cygwin-mingw32|cygwin-mingw64|gcc]"; exit 1;; |
Nguyen Anh Quynh | 26ee41a | 2013-11-27 12:11:31 +0800 | [diff] [blame] | 34 | esac |