mirror of
https://github.com/capstone-engine/capstone.git
synced 2025-02-07 22:56:19 +00:00
This commit is contained in:
parent
e142a11566
commit
dcd5d7b78e
@ -27,6 +27,7 @@ option(CAPSTONE_BUILD_DIET "Build diet library" OFF)
|
||||
option(CAPSTONE_BUILD_TESTS "Build tests" ON)
|
||||
option(CAPSTONE_BUILD_CSTOOL "Build cstool" ON)
|
||||
option(CAPSTONE_USE_DEFAULT_ALLOC "Use default memory allocation functions" ON)
|
||||
option(CAPSTONE_ARCHITECTURE_DEFAULT "Whether architectures are enabled by default" ON)
|
||||
|
||||
set(SUPPORTED_ARCHITECTURES ARM ARM64 M68K MIPS PPC SPARC SYSZ XCORE X86 TMS320C64X M680X EVM MOS65XX WASM BPF RISCV)
|
||||
set(SUPPORTED_ARCHITECTURE_LABELS ARM ARM64 M68K MIPS PowerPC Sparc SystemZ XCore x86 TMS320C64x M680x EVM MOS65XX WASM BPF RISCV)
|
||||
@ -37,7 +38,7 @@ math(EXPR count "${count}-1")
|
||||
foreach(i RANGE ${count})
|
||||
list(GET SUPPORTED_ARCHITECTURES ${i} supported_architecture)
|
||||
list(GET SUPPORTED_ARCHITECTURE_LABELS ${i} supported_architecture_label)
|
||||
option("CAPSTONE_${supported_architecture}_SUPPORT" "${supported_architecture_label} support" ON)
|
||||
option("CAPSTONE_${supported_architecture}_SUPPORT" "${supported_architecture_label} support" ${CAPSTONE_ARCHITECTURE_DEFAULT})
|
||||
endforeach(i)
|
||||
|
||||
# propagate architecture support variables to preprocessor
|
||||
@ -49,7 +50,6 @@ foreach(supported_architecture ${SUPPORTED_ARCHITECTURES})
|
||||
endif()
|
||||
endforeach(supported_architecture)
|
||||
|
||||
option(CAPSTONE_X86_ONLY "Enable just x86, and disable building every other architectures" OFF)
|
||||
option(CAPSTONE_X86_REDUCE "x86 with reduce instruction sets to minimize library" OFF)
|
||||
option(CAPSTONE_X86_ATT_DISABLE "Disable x86 AT&T syntax" OFF)
|
||||
option(CAPSTONE_OSXKERNEL_SUPPORT "Support to embed Capstone into OS X Kernel extensions" OFF)
|
||||
@ -123,7 +123,7 @@ set(HEADERS_COMMON
|
||||
set(TEST_SOURCES test_basic.c test_detail.c test_skipdata.c test_iter.c)
|
||||
|
||||
## architecture support
|
||||
if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_ARM_SUPPORT)
|
||||
if (CAPSTONE_ARM_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_ARM)
|
||||
set(SOURCES_ARM
|
||||
arch/ARM/ARMDisassembler.c
|
||||
@ -152,7 +152,7 @@ if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_ARM_SUPPORT)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_arm.c)
|
||||
endif ()
|
||||
|
||||
if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_ARM64_SUPPORT)
|
||||
if (CAPSTONE_ARM64_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_ARM64)
|
||||
set(SOURCES_ARM64
|
||||
arch/AArch64/AArch64BaseInfo.c
|
||||
@ -183,7 +183,7 @@ if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_ARM64_SUPPORT)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_arm64.c)
|
||||
endif ()
|
||||
|
||||
if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_MIPS_SUPPORT)
|
||||
if (CAPSTONE_MIPS_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_MIPS)
|
||||
set(SOURCES_MIPS
|
||||
arch/Mips/MipsDisassembler.c
|
||||
@ -215,7 +215,7 @@ if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_MIPS_SUPPORT)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_mips.c)
|
||||
endif ()
|
||||
|
||||
if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_PPC_SUPPORT)
|
||||
if (CAPSTONE_PPC_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_POWERPC)
|
||||
set(SOURCES_PPC
|
||||
arch/PowerPC/PPCDisassembler.c
|
||||
@ -303,7 +303,7 @@ if (CAPSTONE_X86_SUPPORT)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_x86.c test_customized_mnem.c)
|
||||
endif ()
|
||||
|
||||
if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_SPARC_SUPPORT)
|
||||
if (CAPSTONE_SPARC_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_SPARC)
|
||||
set(SOURCES_SPARC
|
||||
arch/Sparc/SparcDisassembler.c
|
||||
@ -326,7 +326,7 @@ if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_SPARC_SUPPORT)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_sparc.c)
|
||||
endif ()
|
||||
|
||||
if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_SYSZ_SUPPORT)
|
||||
if (CAPSTONE_SYSZ_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_SYSZ)
|
||||
set(SOURCES_SYSZ
|
||||
arch/SystemZ/SystemZDisassembler.c
|
||||
@ -351,7 +351,7 @@ if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_SYSZ_SUPPORT)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_systemz.c)
|
||||
endif ()
|
||||
|
||||
if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_XCORE_SUPPORT)
|
||||
if (CAPSTONE_XCORE_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_XCORE)
|
||||
set(SOURCES_XCORE
|
||||
arch/XCore/XCoreDisassembler.c
|
||||
@ -372,7 +372,7 @@ if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_XCORE_SUPPORT)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_xcore.c)
|
||||
endif ()
|
||||
|
||||
if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_M68K_SUPPORT)
|
||||
if (CAPSTONE_M68K_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_M68K)
|
||||
set(SOURCES_M68K
|
||||
arch/M68K/M68KDisassembler.c
|
||||
@ -385,7 +385,7 @@ if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_M68K_SUPPORT)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_m68k.c)
|
||||
endif ()
|
||||
|
||||
if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_TMS320C64X_SUPPORT)
|
||||
if (CAPSTONE_TMS320C64X_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_TMS320C64X)
|
||||
set(SOURCES_TMS320C64X
|
||||
arch/TMS320C64x/TMS320C64xDisassembler.c
|
||||
@ -405,7 +405,7 @@ if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_TMS320C64X_SUPPORT)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_tms320c64x.c)
|
||||
endif ()
|
||||
|
||||
if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_M680X_SUPPORT)
|
||||
if (CAPSTONE_M680X_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_M680X)
|
||||
set(SOURCES_M680X
|
||||
arch/M680X/M680XDisassembler.c
|
||||
@ -420,7 +420,7 @@ if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_M680X_SUPPORT)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_m680x.c)
|
||||
endif ()
|
||||
|
||||
if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_EVM_SUPPORT)
|
||||
if (CAPSTONE_EVM_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_EVM)
|
||||
set(SOURCES_EVM
|
||||
arch/EVM/EVMDisassembler.c
|
||||
@ -437,7 +437,7 @@ if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_EVM_SUPPORT)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_evm.c)
|
||||
endif ()
|
||||
|
||||
if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_WASM_SUPPORT)
|
||||
if (CAPSTONE_WASM_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_WASM)
|
||||
set(SOURCES_WASM
|
||||
arch/WASM/WASMDisassembler.c
|
||||
@ -453,7 +453,7 @@ if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_WASM_SUPPORT)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_wasm.c)
|
||||
endif ()
|
||||
|
||||
if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_MOS65XX_SUPPORT)
|
||||
if (CAPSTONE_MOS65XX_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_MOS65XX)
|
||||
set(SOURCES_MOS65XX
|
||||
arch/MOS65XX/MOS65XXModule.c
|
||||
@ -464,7 +464,7 @@ if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_MOS65XX_SUPPORT)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_mos65xx.c)
|
||||
endif ()
|
||||
|
||||
if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_BPF_SUPPORT)
|
||||
if (CAPSTONE_BPF_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_BPF)
|
||||
set(SOURCES_BPF
|
||||
arch/BPF/BPFDisassembler.c
|
||||
@ -482,7 +482,7 @@ if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_BPF_SUPPORT)
|
||||
set(TEST_SOURCES ${TEST_SOURCES} test_bpf.c)
|
||||
endif ()
|
||||
|
||||
if (NOT CAPSTONE_X86_ONLY AND CAPSTONE_RISCV_SUPPORT)
|
||||
if (CAPSTONE_RISCV_SUPPORT)
|
||||
add_definitions(-DCAPSTONE_HAS_RISCV)
|
||||
set(SOURCES_RISCV
|
||||
arch/RISCV/RISCVDisassembler.c
|
||||
|
@ -35,6 +35,9 @@ Get CMake for free from http://www.cmake.org.
|
||||
- CAPSTONE_X86_EVM: support EVM. Run cmake with -DCAPSTONE_EVM_SUPPORT=0 to remove EVM.
|
||||
- CAPSTONE_X86_WASM: support Web Assembly. Run cmake with -DCAPSTONE_WASM_SUPPORT=0 to remove WASM.
|
||||
- CAPSTONE_BPF_SUPPORT: support BPF. Run cmake with -DCAPSTONE_BPF_SUPPORT=0 to remove BPF.
|
||||
- CAPSTONE_ARCHITECUTRE_DEFAULT: Whether architectures are enabled by default.
|
||||
Set this of OFF with -DCAPSTONE_ARCHITECUTRE_DEFAULT=OFF to dissable all architectures by default.
|
||||
You can then enable them again with one of the CAPSTONE_<ARCH>_SUPPORT options.
|
||||
|
||||
By default, all architectures are compiled in.
|
||||
|
||||
@ -58,6 +61,17 @@ Get CMake for free from http://www.cmake.org.
|
||||
(1) CMake allows you to generate different generators to build Capstone. Below is
|
||||
some examples on how to build Capstone on Windows with CMake.
|
||||
|
||||
(*) You can let CMake select a generator for you. Do:
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
|
||||
This last command is also where you can pass additional CMake configuration flags
|
||||
using `-D<key>=<value>`. Then to build use:
|
||||
|
||||
cmake --build . --config Release
|
||||
|
||||
|
||||
(*) To build Capstone using Nmake of Windows SDK, do:
|
||||
|
||||
@ -85,3 +99,20 @@ Get CMake for free from http://www.cmake.org.
|
||||
(2) You can make sure the prior steps successfully worked by launching one of the
|
||||
testing binary (test*.exe).
|
||||
|
||||
(3) You can also enable just one specific architecture by passing the architecture name
|
||||
to either the cmake.sh or nmake.bat scripts. e.g.:
|
||||
|
||||
../cmake.sh x86
|
||||
|
||||
Will just target the x86 architecture. The list of available architectures is: ARM,
|
||||
ARM64, M68K, MIPS, PowerPC, Sparc, SystemZ, XCore, x86, TMS320C64x, M680x, EVM, MOS65XX,
|
||||
WASM, BPF, RISCV.
|
||||
|
||||
(4) You can also create an installation image with cmake, by using the 'install' target.
|
||||
Use:
|
||||
|
||||
cmake --build . --config Release --target install
|
||||
|
||||
This will normally install an image in a default location (`C:\Program Files` on Windows),
|
||||
so it's good to explicitly set this location when configuring CMake. Use: `-DCMAKE_INSTALL_PREFIX=image`
|
||||
for instance, to put the installation in the 'image' subdirectory of the build directory.
|
||||
|
10
cmake-x86.sh
10
cmake-x86.sh
@ -1,10 +0,0 @@
|
||||
# Capstone disassembler engine (www.capstone-engine.org)
|
||||
# Build Capstone libs for X86 only (libcapstone.so & libcapstone.a) on *nix with CMake & make
|
||||
# By Nguyen Anh Quynh, 2019
|
||||
|
||||
# Uncomment below line to compile in Diet mode
|
||||
# cmake -DCMAKE_BUILD_TYPE=Release -DCAPSTONE_BUILD_DIET=ON -DCAPSTONE_X86_ONLY=1 ..
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCAPSTONE_X86_ONLY=1 ..
|
||||
|
||||
make -j8
|
65
cmake.sh
65
cmake.sh
@ -1,10 +1,67 @@
|
||||
# Capstone disassembler engine (www.capstone-engine.org)
|
||||
# Build Capstone libs (libcapstone.so & libcapstone.a) on *nix with CMake & make
|
||||
# By Nguyen Anh Quynh, 2019
|
||||
# Build Capstone libs for specified architecture, or all if none is specified (libcapstone.so & libcapstone.a) on *nix with CMake & make
|
||||
# By Nguyen Anh Quynh, Jorn Vernee, 2019
|
||||
|
||||
FLAGS="-DCMAKE_BUILD_TYPE=Release"
|
||||
# Uncomment below line to compile in Diet mode
|
||||
# cmake -DCMAKE_BUILD_TYPE=Release -DCAPSTONE_BUILD_DIET=ON ..
|
||||
# FLAGS+=" -DCAPSTONE_BUILD_DIET=ON"
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
case $1 in
|
||||
ARM)
|
||||
ARCH=ARM
|
||||
;;
|
||||
ARM64)
|
||||
ARCH=ARM64
|
||||
;;
|
||||
M68K)
|
||||
ARCH=M68K
|
||||
;;
|
||||
MIPS)
|
||||
ARCH=MIPS
|
||||
;;
|
||||
PowerPC)
|
||||
ARCH=PPC
|
||||
;;
|
||||
Sparc)
|
||||
ARCH=SPARC
|
||||
;;
|
||||
SystemZ)
|
||||
ARCH=SYSZ
|
||||
;;
|
||||
XCore)
|
||||
ARCH=XCORE
|
||||
;;
|
||||
x86)
|
||||
ARCH=X86
|
||||
;;
|
||||
TMS320C64x)
|
||||
ARCH=TMS320C64X
|
||||
;;
|
||||
M680x)
|
||||
ARCH=M680X
|
||||
;;
|
||||
EVM)
|
||||
ARCH=EVM
|
||||
;;
|
||||
MOS65XX)
|
||||
ARCH=MOS65XX
|
||||
;;
|
||||
WASM)
|
||||
ARCH=WASM
|
||||
;;
|
||||
BPF)
|
||||
ARCH=BPF
|
||||
;;
|
||||
RISCV)
|
||||
ARCH=RISCV
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
if test "x$ARCH" = "x"; then
|
||||
FLAGS+=" -DCAPSTONE_ARCHITECTURE_DEFAULT=OFF -DCAPSTONE_$ARCH_SUPPORT=ON"
|
||||
fi
|
||||
|
||||
cmake $FLAGS ..
|
||||
|
||||
make -j8
|
||||
|
@ -1,10 +0,0 @@
|
||||
:: Capstone disassembler engine (www.capstone-engine.org)
|
||||
:: Build Capstone libs for X86 only (capstone.dll & capstone.lib) on Windows with CMake & Nmake
|
||||
:: By Nguyen Anh Quynh, 2017
|
||||
|
||||
:: Uncomment below line to compile in Diet mode
|
||||
:: cmake -DCMAKE_BUILD_TYPE=Release -DCAPSTONE_BUILD_DIET=ON -DCAPSTONE_X86_ONLY=1 -DCAPSTONE_BUILD_STATIC_RUNTIME=ON -G "NMake Makefiles" ..
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCAPSTONE_X86_ONLY=1 -DCAPSTONE_BUILD_STATIC_RUNTIME=ON -G "NMake Makefiles" ..
|
||||
|
||||
nmake
|
27
nmake.bat
27
nmake.bat
@ -1,7 +1,30 @@
|
||||
:: Capstone disassembler engine (www.capstone-engine.org)
|
||||
:: Build Capstone libs (capstone.dll & capstone.lib) on Windows with CMake & Nmake
|
||||
:: By Nguyen Anh Quynh, 2017
|
||||
:: By Nguyen Anh Quynh, Jorn Vernee, 2017, 2019
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCAPSTONE_BUILD_STATIC_RUNTIME=ON -G "NMake Makefiles" ..
|
||||
@echo off
|
||||
|
||||
set flags="-DCMAKE_BUILD_TYPE=Release -DCAPSTONE_BUILD_STATIC_RUNTIME=ON"
|
||||
|
||||
if "%1"=="ARM" set %arch%=ARM
|
||||
if "%1"=="ARM64" set %arch%=ARM64
|
||||
if "%1"=="M68K" set %arch%=M68K
|
||||
if "%1"=="MIPS" set %arch%=MIPS
|
||||
if "%1"=="PowerPC" set %arch%=PPC
|
||||
if "%1"=="Sparc" set %arch%=SPARC
|
||||
if "%1"=="SystemZ" set %arch%=SYSZ
|
||||
if "%1"=="XCore" set %arch%=XCORE
|
||||
if "%1"=="x86" set %arch%=X86
|
||||
if "%1"=="TMS320C64x" set %arch%=TMS320C64X
|
||||
if "%1"=="M680x" set %arch%=M680X
|
||||
if "%1"=="EVM" set %arch%=EVM
|
||||
if "%1"=="MOS65XX" set %arch%=MOS65XX
|
||||
if "%1"=="WASM" set %arch%=WASM
|
||||
if "%1"=="BPF" set %arch%=BPF
|
||||
if "%1"=="RISCV" set %arch%=RISCV
|
||||
|
||||
if not "%arch%"=="" set flags=%flags% and " -DCAPSTONE_ARCHITECTURE_DEFAULT=OFF -DCAPSTONE_%arch%_SUPPORT=ON"
|
||||
|
||||
cmake %flags% -G "NMake Makefiles" ..
|
||||
nmake
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user