diff --git a/bindings/python/setup.py b/bindings/python/setup.py index 0a54015f..bb9226b8 100755 --- a/bindings/python/setup.py +++ b/bindings/python/setup.py @@ -70,12 +70,9 @@ def copy_sources(): src.extend(glob.glob(os.path.join(ROOT_DIR, "../../*.[ch]"))) src.extend(glob.glob(os.path.join(ROOT_DIR, "../../*.mk"))) - src.extend(glob.glob(os.path.join(ROOT_DIR, "../../Makefile"))) src.extend(glob.glob(os.path.join(ROOT_DIR, "../../LICENSE*"))) src.extend(glob.glob(os.path.join(ROOT_DIR, "../../README.md"))) src.extend(glob.glob(os.path.join(ROOT_DIR, "../../*.TXT"))) - src.extend(glob.glob(os.path.join(ROOT_DIR, "../../RELEASE_NOTES"))) - src.extend(glob.glob(os.path.join(ROOT_DIR, "../../cmake.sh"))) src.extend(glob.glob(os.path.join(ROOT_DIR, "../../CMakeLists.txt"))) for filename in src: diff --git a/cmake.sh b/cmake.sh deleted file mode 100755 index 23af8f91..00000000 --- a/cmake.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh - -# Unicorn Emulator Engine (www.unicorn-engine.org) -# Usage: cmake.sh [mingw|msys] [x86] [arm] [aarch64] [m68k] [mips] [sparc] [ppc] [riscv] -# By chenhuitao 2019 - -# FLAGS="-DCMAKE_BUILD_TYPE=Release" -FLAGS="-DCMAKE_BUILD_TYPE=Debug" -TOOLCHAIN="" -GENERATOR="Unix Makefiles" -CMAKE="cmake" -COMPILER="" - -# process arguments -case "$1" in - "mingw" ) - TOOLCHAIN="-DCMAKE_TOOLCHAIN_FILE=../mingw-w64.cmake" - shift - UNICORN_ARCH="${*}";; - "msys" ) - shift - UNICORN_ARCH="${*}" - CMAKE="/mingw64/bin/cmake" - GENERATOR="MSYS Makefiles";; - * ) - UNICORN_ARCH="${*}";; -esac - -if [ -n "${COMPILER}" ]; then - TOOLCHAIN="${TOOLCHAIN} -DCMAKE_C_COMPILER=${COMPILER}" -fi - -if [ -z "${UNICORN_ARCH}" ]; then - ${CMAKE} "${FLAGS}" ${TOOLCHAIN} -G "${GENERATOR}" .. -else - ${CMAKE} "${FLAGS}" ${TOOLCHAIN} "-DUNICORN_ARCH=${UNICORN_ARCH}" -G "${GENERATOR}" .. -fi - -# now build -make -j8 diff --git a/docs/COMPILE.md b/docs/COMPILE.md index c499526d..7910d7da 100644 --- a/docs/COMPILE.md +++ b/docs/COMPILE.md @@ -1,55 +1,56 @@ -This HOWTO introduces how to build Unicorn2 natively on Linux/Mac/Windows, -or cross-build to Windows from Linux host. +This HOWTO introduces how to build Unicorn2 natively on Linux/Mac/Windows or cross-build to Windows from Linux host. ---- -### Native build on Linux/MacOS +## Native build on Linux/macOS -This builds Unicorn2 on Linux/MacOS. The output is `libunicorn.so` or `libunicorn.dylib`, respectively. +This builds Unicorn2 on Linux/macOS. Note that this also applies to Apple Silicon M1 users. -- Require `cmake` & `pkg-config` packages (besides `gcc`/`clang` compiler): +- Install `cmake` and `pkg-config` with your favorite package manager: -``` +Ubuntu: + +``` bash $ sudo apt install cmake pkg-config ``` +macOS: + +```bash +$ brew install cmake pkg-config +``` + - Build with the following commands. -``` +```bash $ mkdir build; cd build -$ ../cmake.sh +$ cmake .. -DCMAKE_BUILD_TYPE=Release +$ make ``` -Then run the sample `sample_riscv` with: - -``` -$ ./sample_riscv -``` - ---- ### Native build on Windows, with MSVC -This builds Unicorn2 on Windows, using Microsoft MSVC compiler. The output is `unicorn.dll`. +This builds Unicorn2 on Windows, using Microsoft MSVC compiler. - Require `cmake` & `Microsoft Visual Studio`. - From Visual Studio Command Prompt, build with the following commands. +```bash +mkdir build; cd build +cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release +nmake +``` + +Note, other generators like `Ninja` and `Visual Studio 16 2019` would also work. + ``` mkdir build; cd build -../nmake.sh +cmake .. -G "Visual Studio 16 2019" -A "win32" -DCMAKE_BUILD_TYPE=Release +msbuild unicorn.sln -p:Plaform=Win32 -p:Configuration=Release ``` -Then run the sample `sample_riscv` with: - -``` -sample_riscv.exe -``` - ---- - ### Cross build from Linux host to Windows, with Mingw -This cross-builds Unicorn2 from **Linux host** to Windows, using `Mingw` compiler. The output is `libunicorn.dll` +This cross-builds Unicorn2 from **Linux host** to Windows, using `Mingw` compiler. - Install required package. @@ -61,31 +62,17 @@ $ sudo apt install mingw-w64-x86-64-dev ``` $ mkdir build; cd build -$ ../cmake.sh mingw +$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../mingw64-w64.cmake +$ make ``` -The resulted `sample_riscv.exe` can be run with `libunicorn.dll`, and some dependecies DLLs -already provided in `bin/` directory. - -To prepare for `sample_riscv.exe`, do: - -``` -cp libunicorn.dll ../bin -cp sample_riscv.exe ../bin -``` - -Then inside the `bin/` directory, you can run `sample_riscv.exe` (from `CMD.exe` prompt, for example) - - ---- - ### Native build on Windows host, with MSYS2/Mingw -This builds Unicorn2 on **Windows host**, using **MSYS2/Mingw** compiler. The output is `libunicorn.dll` +This builds Unicorn2 on **Windows host**, using **MSYS2/Mingw** compiler. -This requires MSYS2 to be installed on Windows machine. You need to download & install MSYS2 from https://www.msys2.org. +This requires MSYS2 to be installed on the Windows machine. You need to download & install MSYS2 from https://www.msys2.org. -Then from MSYS2 console, install required packages: +Then from MSYS2 console, install packages below: ``` pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake @@ -95,37 +82,26 @@ pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake ``` mkdir build; cd build -../cmake.sh msys +/mingw64/bin/cmake .. -G "MSYS Makefiles" -DCMAKE_C_COMPILER=/mingw64/bin/gcc.exe -DCMAKE_MAKE_PROGRAM=/mingw64/bin/mingw32-make.exe -DCMAKE_AR=/mingw64/bin/ar.exe -DUNICORN_ARCH=x86 +mingw32-make ``` -The resulted `sample_riscv.exe` can be run with `libunicorn.dll`, and some dependecies DLLs -already provided in `bin/` directory. +Note that the way to build on MSYS changes as time goes, please keep in mind that always use the cmake shipped with mingw64 and choose MSYS Makefiles. -To prepare for `sample_riscv.exe`, do: +### Cross build from Linux host to other architectures -``` -cp libunicorn.dll ../bin -cp sample_riscv.exe ../bin -``` +This cross-builds Unicorn2 from **Linux host** to other architectures, using a cross compiler. -Then inside the `bin/` directory, you can run `sample_riscv.exe` (from `CMD.exe` prompt, for example) - - ---- - -### Cross build from Linux host to other arch - -This cross-builds Unicorn2 from **Linux host** to other arch, using cross compiler. The output is `libunicorn.so` - -- Install cross compiler package. For example, cross compile to ARM require below command. +- Install cross compiler package. For example, cross-compile to ARM requires the below command. ``` $ sudo apt install gcc-arm-linux-gnueabihf ``` -- Build Unicorn and samples with the following commands (note that you need to specify compiler with CC). +- Build Unicorn and samples with the following commands. The compiler name differs according to your targets. ``` $ mkdir build; cd build -$ CC=arm-linux-gnueabihf-gcc ../cmake.sh +$ cmake .. -DCMAKE_C_COMPILER=gcc-arm-linux-gnueabihf +$ make ``` diff --git a/nmake.bat b/nmake.bat deleted file mode 100644 index e3542a29..00000000 --- a/nmake.bat +++ /dev/null @@ -1,40 +0,0 @@ -:: Unicorn Emulator Engine -:: Build Unicorn libs on Windows with CMake & Nmake -:: Usage: nmake.bat [x86 arm aarch64 m68k mips sparc riscv], default build all. -:: By Huitao Chen, 2019 - -@echo off - -set flags="-DCMAKE_BUILD_TYPE=Release" - -set allparams= - -:loop -set str=%1 -if "%str%"=="" ( - goto end -) -set allparams=%allparams% %str% -shift /0 -goto loop - -:end -if "%allparams%"=="" ( - goto eof -) -:: remove left, right blank -:intercept_left -if "%allparams:~0,1%"==" " set "allparams=%allparams:~1%" & goto intercept_left - -:intercept_right -if "%allparams:~-1%"==" " set "allparams=%allparams:~0,-1%" & goto intercept_right - -:eof - -if "%allparams%"=="" ( -cmake "%flags%" -G "NMake Makefiles" .. -) else ( -cmake "%flags%" "-DUNICORN_ARCH=%allparams%" -G "NMake Makefiles" .. -) - -nmake