blob: 268094ec8b63f86cc69a6703c1fa6225a33f7db2 [file] [log] [blame]
Oliver Pinter22062e02014-01-16 09:31:13 +01001#! /usr/bin/env bash
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +08002
3# Capstone Disassembler Engine
4# By Nguyen Anh Quynh <aquynh@gmail.com>, 2013>
5
Nguyen Anh Quynhb8394a42013-11-29 10:26:43 +08006# Note: to cross-compile "nix32" on Linux, package gcc-multilib is required.
7
Daniel Godas-Lopezcf05e112013-11-28 18:23:39 +00008function build {
Oliver Pinter22062e02014-01-16 09:31:13 +01009 if [ ${MAKE}x = x ]; then
10 MAKE=make
11 fi
12
13 CROSS= ${MAKE} clean
Daniel Godas-Lopezcf05e112013-11-28 18:23:39 +000014
15 if [ ${CC}x != x ]; then
Oliver Pinter22062e02014-01-16 09:31:13 +010016 ${MAKE} CC=$CC
Daniel Godas-Lopezcf05e112013-11-28 18:23:39 +000017 else
Oliver Pinter22062e02014-01-16 09:31:13 +010018 ${MAKE}
Daniel Godas-Lopezcf05e112013-11-28 18:23:39 +000019 fi
20}
21
Nguyen Anh Quynh26ee41a2013-11-27 12:11:31 +080022case "$1" in
Daniel Godas-Lopezcf05e112013-11-28 18:23:39 +000023 "" ) build;;
Nguyen Anh Quynh79654d12014-01-08 10:36:59 +080024 "default" ) build;;
Daniel Godas-Lopezcf05e112013-11-28 18:23:39 +000025 "nix32" ) CFLAGS=-m32 LDFLAGS=-m32 build;;
Oliver Pinter22062e02014-01-16 09:31:13 +010026 "bsd") MAKE=gmake PREFIX=/usr/local build;;
Daniel Godas-Lopezcf05e112013-11-28 18:23:39 +000027 "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 Pinter22062e02014-01-16 09:31:13 +010032 "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 Quynh26ee41a2013-11-27 12:11:31 +080034esac