1This documentation explains how to compile, install & run Capstone on MacOSX, 2Linux, *BSD & Solaris. We also show steps to cross-compile for Microsoft Windows. 3 4To natively compile for Windows using Microsoft Visual Studio, see COMPILE_MSVC.TXT. 5 6To compile using CMake, see COMPILE_CMAKE.TXT. 7 8To compile using XCode on MacOSX, see xcode/README.md. 9 10To compile for Windows CE (a.k.a, Windows Embedded Compact), see windowsce/COMPILE.md. 11 12 *-*-*-*-*-* 13 14Capstone requires no prerequisite packages, so it is easy to compile & install. 15 16 17 18(0) Tailor Capstone to your need. 19 20 Out of all archtitectures supported by Capstone, if you just need several 21 selected archs, choose the ones you want to compile in by editing "config.mk" 22 before going to next steps. 23 24 By default, all architectures are compiled. 25 26 The other way of customize Capstone without having to edit config.mk is to 27 pass the desired options on the commandline to ./make.sh. Currently, 28 Capstone supports 7 options, as followings. 29 30 - CAPSTONE_ARCHS: specify list of architectures to compiled in. 31 - CAPSTONE_USE_SYS_DYN_MEM: change this if you have your own dynamic memory management. 32 - CAPSTONE_DIET: use this to make the output binaries more compact. 33 - CAPSTONE_X86_REDUCE: another option to make X86 binary smaller. 34 - CAPSTONE_X86_ATT_DISABLE: disables AT&T syntax on x86. 35 - CAPSTONE_STATIC: build static library. 36 - CAPSTONE_SHARED: build dynamic (shared) library. 37 38 By default, Capstone uses system dynamic memory management, both DIET and X86_REDUCE 39 modes are disable, and builds all the static & shared libraries. 40 41 To avoid editing config.mk for these customization, we can pass their values to 42 make.sh, as followings. 43 44 $ CAPSTONE_ARCHS="arm aarch64 x86" CAPSTONE_USE_SYS_DYN_MEM=no CAPSTONE_DIET=yes CAPSTONE_X86_REDUCE=yes ./make.sh 45 46 NOTE: on commandline, put these values in front of ./make.sh, not after it. 47 48 For each option, refer to docs/README for more details. 49 50 51 52(1) Compile from source 53 54 On *nix (such as MacOSX, Linux, *BSD, Solaris): 55 56 - To compile for current platform, run: 57 58 $ ./make.sh 59 60 - On 64-bit OS, run the command below to cross-compile Capstone for 32-bit binary: 61 62 $ ./make.sh nix32 63 64 65 66(2) Install Capstone on *nix 67 68 To install Capstone, run: 69 70 $ sudo ./make.sh install 71 72 For FreeBSD/OpenBSD, where sudo is unavailable, run: 73 74 $ su; ./make.sh install 75 76 Users are then required to enter root password to copy Capstone into machine 77 system directories. 78 79 Afterwards, run ./tests/test* to see the tests disassembling sample code. 80 81 82 NOTE: The core framework installed by "./make.sh install" consist of 83 following files: 84 85 /usr/include/capstone/arm.h 86 /usr/include/capstone/arm64.h 87 /usr/include/capstone/capstone.h 88 /usr/include/capstone/evm.h 89 /usr/include/capstone/m680x.h 90 /usr/include/capstone/m68k.h 91 /usr/include/capstone/mips.h 92 /usr/include/capstone/mos65xx.h 93 /usr/include/capstone/platform.h 94 /usr/include/capstone/ppc.h 95 /usr/include/capstone/sparc.h 96 /usr/include/capstone/systemz.h 97 /usr/include/capstone/tms320c64x.h 98 /usr/include/capstone/x86.h 99 /usr/include/capstone/xcore.h 100 /usr/lib/libcapstone.a 101 /usr/lib/libcapstone.so (for Linux/*nix), or /usr/lib/libcapstone.dylib (OSX) 102 103 104 105(3) Cross-compile for Windows from *nix 106 107 To cross-compile for Windows, Linux & gcc-mingw-w64-i686 (and also gcc-mingw-w64-x86-64 108 for 64-bit binaries) are required. 109 110 - To cross-compile Windows 32-bit binary, simply run: 111 112 $ ./make.sh cross-win32 113 114 - To cross-compile Windows 64-bit binary, run: 115 116 $ ./make.sh cross-win64 117 118 Resulted files libcapstone.dll, libcapstone.dll.a & tests/test*.exe can then 119 be used on Windows machine. 120 121 122 123(4) Cross-compile for iOS from Mac OSX. 124 125 To cross-compile for iOS (iPhone/iPad/iPod), Mac OSX with XCode installed is required. 126 127 - To cross-compile for ArmV7 (iPod 4, iPad 1/2/3, iPhone4, iPhone4S), run: 128 $ ./make.sh ios_armv7 129 130 - To cross-compile for ArmV7s (iPad 4, iPhone 5C, iPad mini), run: 131 $ ./make.sh ios_armv7s 132 133 - To cross-compile for Arm64 (iPhone 5S, iPad mini Retina, iPad Air), run: 134 $ ./make.sh ios_arm64 135 136 - To cross-compile for all iDevices (armv7 + armv7s + arm64), run: 137 $ ./make.sh ios 138 139 Resulted files libcapstone.dylib, libcapstone.a & tests/test* can then 140 be used on iOS devices. 141 142 143 144(5) Cross-compile for Android 145 146 To cross-compile for Android (smartphone/tablet), Android NDK is required. 147 NOTE: Only ARM and ARM64 are currently supported. 148 149 $ NDK=/android/android-ndk-r10e ./make.sh cross-android arm 150 or 151 $ NDK=/android/android-ndk-r10e ./make.sh cross-android arm64 152 153 Resulted files libcapstone.so, libcapstone.a & tests/test* can then 154 be used on Android devices. 155 156 157 158(6) Compile on Windows with Cygwin 159 160 To compile under Cygwin gcc-mingw-w64-i686 or x86_64-w64-mingw32 run: 161 162 - To compile Windows 32-bit binary under Cygwin, run: 163 164 $ ./make.sh cygwin-mingw32 165 166 - To compile Windows 64-bit binary under Cygwin, run: 167 168 $ ./make.sh cygwin-mingw64 169 170 Resulted files libcapstone.dll, libcapstone.dll.a & tests/test*.exe can then 171 be used on Windows machine. 172 173 174 175(7) By default, "cc" (default C compiler on the system) is used as compiler. 176 177 - To use "clang" compiler instead, run the command below: 178 179 $ ./make.sh clang 180 181 - To use "gcc" compiler instead, run: 182 183 $ ./make.sh gcc 184 185 186 187(8) To uninstall Capstone, run the command below: 188 189 $ sudo ./make.sh uninstall 190 191 192 193(9) Language bindings 194 195 So far, Python, Ocaml & Java are supported by bindings in the main code. 196 Look for the bindings under directory bindings/, and refer to README file 197 of corresponding languages. 198 199 Community also provide bindings for C#, Go, Ruby, NodeJS, C++ & Vala. Links to 200 these can be found at address http://capstone-engine.org/download.html 201