2022-09-22 12:36:57 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, pkg-config
|
|
|
|
, fixDarwinDylibNames
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "capstone";
|
2020-05-29 06:06:01 +00:00
|
|
|
version = "4.0.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-01-03 16:56:52 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "aquynh";
|
|
|
|
repo = "capstone";
|
|
|
|
rev = version;
|
|
|
|
sha256 = "sha256-XMwQ7UaPC8YYu4yxsE4bbR3leYPfBHu5iixSLz05r3g=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# replace faulty macos detection
|
2021-02-05 17:12:51 +00:00
|
|
|
postPatch = lib.optionalString stdenv.isDarwin ''
|
2020-04-24 23:36:52 +00:00
|
|
|
sed -i 's/^IS_APPLE := .*$/IS_APPLE := 1/' Makefile
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
configurePhase = "patchShebangs make.sh ";
|
2020-04-24 23:36:52 +00:00
|
|
|
buildPhase = "PREFIX=$out ./make.sh";
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
|
|
|
# first remove fuzzing steps from check target
|
|
|
|
substituteInPlace Makefile --replace "fuzztest fuzzallcorp" ""
|
|
|
|
make check
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
installPhase = (lib.optionalString stdenv.isDarwin "HOMEBREW_CAPSTONE=1 ")
|
2020-04-24 23:36:52 +00:00
|
|
|
+ "PREFIX=$out ./make.sh install";
|
2021-02-05 17:12:51 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [
|
2021-02-05 17:12:51 +00:00
|
|
|
pkg-config
|
2022-09-22 12:36:57 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
fixDarwinDylibNames
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Advanced disassembly library";
|
|
|
|
homepage = "http://www.capstone-engine.org";
|
2021-02-05 17:12:51 +00:00
|
|
|
license = lib.licenses.bsd3;
|
|
|
|
maintainers = with lib.maintainers; [ thoughtpolice ris ];
|
2022-05-18 14:49:53 +00:00
|
|
|
mainProgram = "cstool";
|
|
|
|
platforms = lib.platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|