1{ stdenv, lib, fetchpatch, buildPackages, fetchurl, gettext
2, genPosixLockObjOnly ? false
3}: let
4 genPosixLockObjOnlyAttrs = lib.optionalAttrs genPosixLockObjOnly {
5 buildPhase = ''
6 cd src
7 make gen-posix-lock-obj
8 '';
9
10 installPhase = ''
11 mkdir -p $out/bin
12 install -m755 gen-posix-lock-obj $out/bin
13 '';
14
15 outputs = [ "out" ];
16 outputBin = "out";
17 };
18in stdenv.mkDerivation (rec {
19 name = "libgpg-error-${version}";
20 version = "1.34";
21
22 src = fetchurl {
23 url = "mirror://gnupg/libgpg-error/${name}.tar.bz2";
24 sha256 = "10cc76y7zi6wsdmpy1abf3i0q17bj59q5ysy8cpnpf3ixsfpk006";
25 };
26
27 postPatch = ''
28 sed '/BUILD_TIMESTAMP=/s/=.*/=1970-01-01T00:01+0000/' -i ./configure
29 '' + lib.optionalString (stdenv.hostPlatform.isAarch32 && stdenv.buildPlatform != stdenv.hostPlatform) ''
30 ln -s lock-obj-pub.arm-unknown-linux-gnueabi.h src/syscfg/lock-obj-pub.linux-gnueabihf.h
31 '' + lib.optionalString (stdenv.hostPlatform.isx86_64 && stdenv.hostPlatform.isMusl) ''
32 ln -s lock-obj-pub.x86_64-pc-linux-musl.h src/syscfg/lock-obj-pub.linux-musl.h
33 '' + lib.optionalString (stdenv.hostPlatform.isAarch32 && stdenv.hostPlatform.isMusl) ''
34 ln -s src/syscfg/lock-obj-pub.arm-unknown-linux-gnueabi.h src/syscfg/lock-obj-pub.arm-unknown-linux-musleabihf.h
35 ln -s src/syscfg/lock-obj-pub.arm-unknown-linux-gnueabi.h src/syscfg/lock-obj-pub.linux-musleabihf.h
36 '';
37
38 outputs = [ "out" "dev" "info" ];
39 outputBin = "dev"; # deps want just the lib, most likely
40
41 # If architecture-dependent MO files aren't available, they're generated
42 # during build, so we need gettext for cross-builds.
43 depsBuildBuild = [ buildPackages.stdenv.cc ];
44 nativeBuildInputs = [ gettext ];
45
46 postConfigure =
47 lib.optionalString stdenv.isSunOS
48 # For some reason, /bin/sh on OpenIndiana leads to this at the end of the
49 # `config.status' run:
50 # ./config.status[1401]: shift: (null): bad number
51 # (See <http://hydra.nixos.org/build/2931046/nixlog/1/raw>.)
52 # Thus, re-run it with Bash.
53 "${stdenv.shell} config.status";
54
55 doCheck = true; # not cross
56
57 meta = with stdenv.lib; {
58 homepage = https://www.gnupg.org/related_software/libgpg-error/index.html;
59 description = "A small library that defines common error values for all GnuPG components";
60
61 longDescription = ''
62 Libgpg-error is a small library that defines common error values
63 for all GnuPG components. Among these are GPG, GPGSM, GPGME,
64 GPG-Agent, libgcrypt, Libksba, DirMngr, Pinentry, SmartCard
65 Daemon and possibly more in the future.
66 '';
67
68 license = licenses.lgpl2Plus;
69 platforms = platforms.all;
70 maintainers = [ maintainers.fuuzetsu maintainers.vrthra ];
71 };
72} // genPosixLockObjOnlyAttrs)