| 1 | This documentation explains how to compile Capstone for: |
| 2 | - Windows CE 7, a.k.a, [Windows Embedded Compact 7](https://www.microsoft.com/windowsembedded/en-us/windows-embedded-compact-7.aspx), on [ARMv7](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0406c/index.html). |
| 3 | - Windows CE 8, a.k.a, [Windows Embedded Compact 2013](https://www.microsoft.com/windowsembedded/en-us/windows-embedded-compact-2013.aspx), on [ARMv7](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0406c/index.html). |
| 4 | |
| 5 | To build Capstone for a different platform, please refer to `COMPILE.TXT`. |
| 6 | |
| 7 | # Prerequisites |
| 8 | |
| 9 | We support the following scenario regarding the build machine: |
| 10 | - Build running on Microsoft Windows. |
| 11 | - The C Software Develepment Kit of the target Windows CE **device** installed. |
| 12 | - Only for Windows CE 7: |
| 13 | - C compiler toolchain installed, targetting **Windows Embedded Compact 7** on **ARMv7**. We recommend the toolchain provided with [Windows Embedded Compact 7 toolkit](https://msdn.microsoft.com/en-us/library/jj200349%28v=winembedded.70%29.aspx), as the toolchain originally provided with **Visual Studio 2008** is relatively old. |
| 14 | |
| 15 | Before building Capstone for Windows CE 7 (respectively, Windows CE 8), the build script `windowsce/make_windowsce7-armv7.bat` (respectively, `windowsce/make_windowsce8-armv7.bat`) needs to be modified. The variables specified in the rest of this section are set in this script file. |
| 16 | |
| 17 | # Toolchain specification |
| 18 | |
| 19 | The following information need to be specified in the build script in order to perform the build: |
| 20 | - `set WINCE_TOOLCHAIN_ROOT=` is the path of the root directory of the Windows CE toolchain. To build for Windows CE 7, this should be set to the Windows Embedded Compact 7 toolchain. To build for Windows CE 8, this should be set to the device toolchain. |
| 21 | Examples: |
| 22 | - For Windows CE 7: |
| 23 | ```bat |
| 24 | set WINCE_TOOLCHAIN_ROOT=C:\WINCE700\sdk |
| 25 | ``` |
| 26 | - For Windows CE 8: |
| 27 | ```bat |
| 28 | set WINCE_TOOLCHAIN_ROOT=C:\Windows_CE_Tools\SDKs\SDK_HW90270\Sdk |
| 29 | ``` |
| 30 | |
| 31 | - `set TOOLCHAIN=` is a semicolon-separated list of the paths of the directories containing the binaries of the Windows CE toolchain. |
| 32 | For example: |
| 33 | ```bat |
| 34 | set TOOLCHAIN=%WINCE_TOOLCHAIN_ROOT%\Bin\i386\Arm;%WINCE_TOOLCHAIN_ROOT%\Bin\i386 |
| 35 | ``` |
| 36 | |
| 37 | - `set INCLUDE=` is a semicolon-separated list of the paths of the directories containing the C header files of the Windows CE device SDK. To build for Windows CE 7, this should also include the directories containing the C header files of the Windows Embedded Compact 7 toolchain. |
| 38 | Examples: |
| 39 | - For Windows CE 7: |
| 40 | ```bat |
| 41 | set INCLUDE=C:\Program Files (x86)\Windows CE Tools\SDKs\Symbol MC3200c70 Windows CE 7.0 PSDK\Include\Armv4i;C:\WINCE700\public\common\sdk\inc |
| 42 | ``` |
| 43 | - For Windows CE 8: |
| 44 | ```bat |
| 45 | set INCLUDE=%WINCE_TOOLCHAIN_ROOT%\Inc;%WINCE_TOOLCHAIN_ROOT%\crt\Include |
| 46 | ``` |
| 47 | |
| 48 | - `set LIBPATH=` is a semicolon-separated list of the paths of the directories containing the library (i.e., `.LIB`) files of the Windows CE 7 device SDK. |
| 49 | Examples: |
| 50 | - For Windows CE 7: |
| 51 | ```bat |
| 52 | set LIBPATH=C:\Program Files (x86)\Windows CE Tools\SDKs\Symbol MC3200c70 Windows CE 7.0 PSDK\Lib\ARMv4I |
| 53 | ``` |
| 54 | - For Windows CE 8: |
| 55 | ```bat |
| 56 | set LIBPATH=%WINCE_TOOLCHAIN_ROOT%\Lib\ARMV7\retail;%WINCE_TOOLCHAIN_ROOT%\Crt\Lib\ARM |
| 57 | ``` |
| 58 | |
| 59 | - `set LIBS=` is a space-separated list of linker directives controlling library search. |
| 60 | Examples: |
| 61 | - For Windows CE 7: |
| 62 | ```bat |
| 63 | set LIBS=-nodefaultlib:oldnames.lib -nodefaultlib:libcmtd.lib -nodefaultlib:libcmt.lib coredll.lib corelibc.lib |
| 64 | ``` |
| 65 | - For Windows CE 8: |
| 66 | ```bat |
| 67 | set LIBS=coredll.lib |
| 68 | ``` |
| 69 | |
| 70 | # Capstone binary format |
| 71 | |
| 72 | By default, the build script produces a **dynamic link library** (i.e., `.DLL`). In order to produce a **static library** (i.e., `.LIB`) instead, the `SHARED` variable needs to be set to `0`, i.e.: |
| 73 | ```bat |
| 74 | set SHARED=0 |
| 75 | ``` |
| 76 | |
| 77 | # Architectures supported at runtime |
| 78 | |
| 79 | Capstone supports the following architectures: ARM, ARM64 (AArch64), M68K, MIPS, PowerPC, Sparc, SystemZ, x86 and XCore. However, Capstone can be configured in order to select which architectures need to be supported **at runtime**. This is controlled via the variable `DISASM_ARCH_LIST`, which is a space-separated list that is a combination of the following names: |
| 80 | - `ARM` |
| 81 | - `ARM64` |
| 82 | - `M68K` |
| 83 | - `MIPS` |
| 84 | - `POWERPC` |
| 85 | - `SPARC` |
| 86 | - `SYSZ` |
| 87 | - `X86` |
| 88 | - `XCORE`. |
| 89 | |
| 90 | By default, `DISASM_ARCH_LIST` includes support for **all** architectures supported by Capstone. |
| 91 | For example: |
| 92 | ```bat |
| 93 | set DISASM_ARCH_LIST=ARM ARM64 X86 |
| 94 | ``` |
| 95 | will produce a Capstone binary that supports the following architectures: ARM, ARM64 and x86. |
| 96 | |
| 97 | ## Features customization |
| 98 | |
| 99 | Capstone has a list of features that can be controlled when needed. Each feature is controlled through setting a variable from the following list: |
| 100 | |
| 101 | - In order to produce a smaller binary that provides a **subset** of the features of Capstone, but still supports all the selected architectures, please specify the following: |
| 102 | ```bat |
| 103 | set DIET_MODE=1 |
| 104 | ``` |
| 105 | By default, this variable is set to `0`. |
| 106 | |
| 107 | - By default, Capstone uses the default system-provided **dynamic memory management** functions (e.g., `malloc()`, `realloc()`, `free()`) for its internal memory management. However, Capstone can instead be configured to call **custom** memory management functions provided by client applications. In order to enable this behavior, set the following: |
| 108 | ```bat |
| 109 | set USE_SYS_DYN_MEM=0 |
| 110 | ``` |
| 111 | |
| 112 | - In order to produce a **smaller** Capstone binary, support for the `x86` architecture can be more **limited**. In order to do so, set the following: |
| 113 | ```bat |
| 114 | set X86_REDUCE=1 |
| 115 | ``` |
| 116 | By default, this is set to `0`. |
| 117 | |
| 118 | - If the **AT&T** disassembly style of the `x86` architecture is never needed at runtime, then disabling support for it can produce a **smaller** Capstone binary. To do this, please set the following: |
| 119 | ```bat |
| 120 | set X86_ATT_DISABLE=1 |
| 121 | ``` |
| 122 | By default, this is set to `0`. |
| 123 | |
| 124 | Please refer to `docs/README` for more details on these features. |