summary refs log tree commit diff
path: root/pkgs/development/tools/boomerang/default.nix
blob: a17529c28375ac13e8f37dd44b5b25f6f48a0554 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{ stdenv, fetchgit, cmake, expat }:

stdenv.mkDerivation rec {
  name = "boomerang-${version}";
  version = "0.3.2alpha";

  src = fetchgit {
    url = "https://github.com/nemerle/boomerang.git";
    rev = "78c6b9dd33790be43dcb07edc549161398904006";
    sha256 = "1hh8v0kcnipwrfz4d45d6pm5bzbm9wgbrdgg0ir2l7wyshbkff6i";
  };

  buildInputs = [ cmake expat ];

  postPatch = ''
    sed -i -e 's/-std=c++0x/-std=c++11 -fpermissive/' CMakeLists.txt

    # Hardcode library base path ("lib/" is appended elsewhere)
    sed -i -e 's|::m_base_path = "|&'"$out"'/|' loader/BinaryFileFactory.cpp
    # Deactivate setting base path at runtime
    sed -i -e 's/m_base_path *=[^}]*//' include/BinaryFile.h

    # Fix up shared directory locations
    shared="$out/share/boomerang/"
    find frontend -name '*.cpp' -print | xargs sed -i -e \
      's|Boomerang::get()->getProgPath()|std::string("'"$shared"'")|'

    cat >> loader/CMakeLists.txt <<CMAKE
    INSTALL(TARGETS bffDump BinaryFile
            ElfBinaryFile Win32BinaryFile ExeBinaryFile HpSomBinaryFile
            PalmBinaryFile DOS4GWBinaryFile MachOBinaryFile
            RUNTIME DESTINATION bin
            LIBRARY DESTINATION lib)
    CMAKE

    cat >> CMakeLists.txt <<CMAKE
    INSTALL(TARGETS boomerang DESTINATION bin)
    INSTALL(DIRECTORY signatures DESTINATION share/boomerang)
    INSTALL(DIRECTORY frontend/machine DESTINATION share/boomerang/frontend)
    CMAKE
  '';

  enableParallelBuilding = true;

  meta = {
    homepage = "http://boomerang.sourceforge.net/";
    license = stdenv.lib.licenses.bsd3;
    description = "A general, open source, retargetable decompiler";
  };
}