about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/capstone
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/capstone')
-rw-r--r--nixpkgs/pkgs/development/libraries/capstone/default.nix43
1 files changed, 43 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/capstone/default.nix b/nixpkgs/pkgs/development/libraries/capstone/default.nix
new file mode 100644
index 000000000000..b8d00984cd64
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/capstone/default.nix
@@ -0,0 +1,43 @@
+{ stdenv, fetchurl, pkgconfig }:
+
+stdenv.mkDerivation rec {
+  pname = "capstone";
+  version = "4.0.1";
+
+  src = fetchurl {
+    url    = "https://github.com/aquynh/capstone/archive/${version}.tar.gz";
+    sha256 = "1isxw2qwy1fi3m3w7igsr5klzczxc5cxndz0a78dfss6ps6ymfvr";
+  };
+
+  # replace faulty macos detection
+  postPatch = stdenv.lib.optionalString stdenv.isDarwin ''
+    sed -i 's/^IS_APPLE := .*$/IS_APPLE := 1/' Makefile
+  '';
+
+  configurePhase = '' patchShebangs make.sh '';
+  buildPhase = "PREFIX=$out ./make.sh";
+
+  doCheck = true;
+  checkPhase = ''
+    # first remove fuzzing steps from check target
+    substituteInPlace Makefile --replace "fuzztest fuzzallcorp" ""
+    make check
+  '';
+
+  installPhase = (stdenv.lib.optionalString stdenv.isDarwin "HOMEBREW_CAPSTONE=1 ")
+    + "PREFIX=$out ./make.sh install";
+  
+  nativeBuildInputs = [
+    pkgconfig
+  ];
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "Advanced disassembly library";
+    homepage    = "http://www.capstone-engine.org";
+    license     = stdenv.lib.licenses.bsd3;
+    platforms   = stdenv.lib.platforms.unix;
+    maintainers = with stdenv.lib.maintainers; [ thoughtpolice ris ];
+  };
+}