1{ lib, stdenv
2, fetchurl, autoreconfHook, gettext, freebsd, netbsd
3}:
4
5# Note: this package is used for bootstrapping fetchurl, and thus
6# cannot use fetchpatch! All mutable patches (generated by GitHub or
7# cgit) that are needed here should be included directly in Nixpkgs as
8# files.
9
10stdenv.mkDerivation rec {
11 pname = "libelf";
12 version = "0.8.13";
13
14 src = fetchurl {
15 url = "https://fossies.org/linux/misc/old/${pname}-${version}.tar.gz";
16 sha256 = "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr";
17 };
18
19 patches = [
20 ./dont-hardcode-ar.patch
21 # Fix warnings from preprocessor instructions.
22 # https://github.com/NixOS/nixpkgs/issues/59929
23 ./preprocessor-warnings.patch
24 ];
25
26 enableParallelBuilding = true;
27 # Lacks dependencies:
28 # mkdir ...-libelf-0.8.13/lib
29 # mkdir ...-libelf-0.8.13/lib
30 # mkdir: cannot create directory '...-libelf-0.8.13/lib': File exists
31 enableParallelInstalling = false;
32
33 doCheck = true;
34
35 preConfigure = if !stdenv.hostPlatform.useAndroidPrebuilt then null else ''
36 sed -i 's|DISTSUBDIRS = lib po|DISTSUBDIRS = lib|g' Makefile.in
37 sed -i 's|SUBDIRS = lib @POSUB@|SUBDIRS = lib|g' Makefile.in
38 '';
39
40 configureFlags = []
41 # Configure check for dynamic lib support is broken, see
42 # http://lists.uclibc.org/pipermail/uclibc-cvs/2005-August/019383.html
43 ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "mr_cv_target_elf=yes"
44 # Libelf's custom NLS macros fail to determine the catalog file extension
45 # on Darwin, so disable NLS for now.
46 ++ lib.optional stdenv.hostPlatform.isDarwin "--disable-nls";
47
48 strictDeps = true;
49 nativeBuildInputs =
50 (if stdenv.hostPlatform.isFreeBSD then [ freebsd.gencat ]
51 else if stdenv.hostPlatform.isNetBSD then [ netbsd.gencat ]
52 else [ gettext ])
53 # Need to regenerate configure script with newer version in order to pass
54 # "mr_cv_target_elf=yes" and determine integer sizes correctly when
55 # cross-compiling, but `autoreconfHook` brings in `makeWrapper` which
56 # doesn't work with the bootstrapTools bash, so can only do this for
57 # cross builds when `stdenv.shell` is a newer bash.
58 ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) autoreconfHook;
59
60 meta = {
61 description = "ELF object file access library";
62
63 homepage = "https://github.com/Distrotech/libelf";
64
65 license = lib.licenses.lgpl2Plus;
66
67 platforms = lib.platforms.all;
68 maintainers = [ ];
69 };
70}