1{
2 lib,
3 stdenv,
4 fetchpatch,
5 gnu-config,
6 autoreconfHook,
7 bison,
8 binutils-unwrapped_2_38,
9 libiberty,
10 libintl,
11 zlib,
12}:
13
14stdenv.mkDerivation {
15 pname = "libbfd";
16 inherit (binutils-unwrapped_2_38) version src;
17
18 outputs = [
19 "out"
20 "dev"
21 ];
22
23 patches = binutils-unwrapped_2_38.patches ++ [
24 ./build-components-separately.patch
25 (fetchpatch {
26 url = "https://raw.githubusercontent.com/mxe/mxe/e1d4c144ee1994f70f86cf7fd8168fe69bd629c6/src/bfd-1-disable-subdir-doc.patch";
27 sha256 = "0pzb3i74d1r7lhjan376h59a7kirw15j7swwm8pz3zy9lkdqkj6q";
28 })
29 ];
30
31 # We just want to build libbfd
32 postPatch = ''
33 cd bfd
34 '';
35
36 postAutoreconf = ''
37 echo "Updating config.guess and config.sub from ${gnu-config}"
38 cp -f ${gnu-config}/config.{guess,sub} ../
39 '';
40
41 # We update these ourselves
42 dontUpdateAutotoolsGnuConfigScripts = true;
43
44 strictDeps = true;
45 nativeBuildInputs = [
46 autoreconfHook
47 bison
48 ];
49 buildInputs = [
50 libiberty
51 zlib
52 ]
53 ++ lib.optionals stdenv.hostPlatform.isDarwin [ libintl ];
54
55 configurePlatforms = [
56 "build"
57 "host"
58 ];
59 configureFlags = [
60 "--enable-targets=all"
61 "--enable-64-bit-bfd"
62 "--enable-install-libbfd"
63 "--with-system-zlib"
64 ]
65 ++ lib.optional (!stdenv.hostPlatform.isStatic) "--enable-shared";
66
67 enableParallelBuilding = true;
68
69 meta = with lib; {
70 description = "Library for manipulating containers of machine code";
71 longDescription = ''
72 BFD is a library which provides a single interface to read and write
73 object files, executables, archive files, and core files in any format.
74 It is associated with GNU Binutils, and elsewhere often distributed with
75 it.
76 '';
77 homepage = "https://www.gnu.org/software/binutils/";
78 license = licenses.gpl3Plus;
79 maintainers = with maintainers; [ ericson2314 ];
80 platforms = platforms.unix;
81 };
82}