1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 enableStatic ? true,
7 enableShared ? !stdenv.hostPlatform.isStatic,
8}:
9
10stdenv.mkDerivation rec {
11 pname = "libexecinfo";
12 version = "1.1";
13
14 src = fetchurl {
15 url = "http://distcache.freebsd.org/local-distfiles/itetcu/${pname}-${version}.tar.bz2";
16 sha256 = "07wvlpc1jk1sj4k5w53ml6wagh0zm9kv2l1jngv8xb7xww9ik8n9";
17 };
18
19 patches = [
20 (fetchpatch {
21 name = "10-execinfo.patch";
22 url = "https://git.alpinelinux.org/aports/plain/main/libexecinfo/10-execinfo.patch?id=730cdcef6901750f4029d4c3b8639ce02ee3ead1";
23 sha256 = "0lnphrad4vspyljnvmm62dyxj98vgp3wabj4w3vfzfph7j8piw7g";
24 })
25 (fetchpatch {
26 name = "20-define-gnu-source.patch";
27 url = "https://git.alpinelinux.org/aports/plain/main/libexecinfo/20-define-gnu-source.patch?id=730cdcef6901750f4029d4c3b8639ce02ee3ead1";
28 sha256 = "1mp8mc639b0h2s69m5z6s2h3q3n1zl298j9j0plzj7f979j76302";
29 })
30 ./30-linux-makefile.patch
31 ];
32
33 makeFlags = [
34 "CC:=$(CC)"
35 "AR:=$(AR)"
36 ];
37 hardeningEnable = [ "stackprotector" ];
38
39 buildFlags = lib.optional enableStatic "static" ++ lib.optional enableShared "dynamic";
40
41 patchFlags = [ "-p0" ];
42
43 installPhase = ''
44 install -Dm644 execinfo.h stacktraverse.h -t $out/include
45 ''
46 + lib.optionalString enableShared ''
47 install -Dm755 libexecinfo.so.1 -t $out/lib
48 ln -s $out/lib/libexecinfo.so{.1,}
49 ''
50 + lib.optionalString enableStatic ''
51 install -Dm755 libexecinfo.a -t $out/lib
52 '';
53
54 meta = with lib; {
55 description = "Quick-n-dirty BSD licensed clone of the GNU libc backtrace facility";
56 license = licenses.bsd2;
57 homepage = "https://www.freshports.org/devel/libexecinfo";
58 maintainers = [ ];
59 };
60}