@@ -1,5 +1,24 @@
11{ stdenv, fetchurl, fetchpatch }:
22
3+let
4+ patch-argp-fmtstream = fetchpatch {
5+ name = "patch-argp-fmtstream.h";
6+ url = "https://raw.githubusercontent.com/Homebrew/formula-patches/b5f0ad3/argp-standalone/patch-argp-fmtstream.h";
7+ sha256 = "5656273f622fdb7ca7cf1f98c0c9529bed461d23718bc2a6a85986e4f8ed1cb8";
8+ };
9+
10+ patch-throw-in-funcdef = fetchpatch {
11+ name = "argp-standalone-1.3-throw-in-funcdef.patch";
12+ url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/sys-libs/argp-standalone/files/argp-standalone-1.3-throw-in-funcdef.patch?id=409d0e2a9c9c899fb1fb04cc808fe0aff3f745ca";
13+ sha256 = "0b2b4l1jkvmnffl22jcn4ydzxy2i7fnmmnfim12f0yg5pb8fs43c";
14+ };
15+
16+ patch-shared = fetchpatch {
17+ name = "argp-standalone-1.3-shared.patch";
18+ url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/sys-libs/argp-standalone/files/argp-standalone-1.3-shared.patch?id=409d0e2a9c9c899fb1fb04cc808fe0aff3f745ca";
19+ sha256 = "1xx2zdc187a1m2x6c1qs62vcrycbycw7n0q3ks2zkxpaqzx2dgkw";
20+ };
21+in
322stdenv.mkDerivation rec {
423 name = "argp-standalone-1.3";
524
@@ -8,24 +27,19 @@ stdenv.mkDerivation rec {
827 sha256 = "dec79694da1319acd2238ce95df57f3680fea2482096e483323fddf3d818d8be";
928 };
1029
11− patches = [
12− (if stdenv.hostPlatform.isDarwin then
13− fetchpatch {
14− name = "patch-argp-fmtstream.h";
15− url = "https://raw.githubusercontent.com/Homebrew/formula-patches/b5f0ad3/argp-standalone/patch-argp-fmtstream.h";
16− sha256 = "5656273f622fdb7ca7cf1f98c0c9529bed461d23718bc2a6a85986e4f8ed1cb8";
17− }
18− else null)
19− ];
20−
21− patchFlags = "-p0";
22−
23− postInstall =
24− ''
25− mkdir -p $out/lib $out/include
26− cp libargp.a $out/lib
27− cp argp.h $out/include
28− '';
30+ patches =
31+ stdenv.lib.optionals stdenv.hostPlatform.isDarwin [ patch-argp-fmtstream ]
32+ ++ stdenv.lib.optionals stdenv.hostPlatform.isLinux [ patch-throw-in-funcdef patch-shared ];
33+
34+ patchFlags = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "-p0";
35+
36+ preConfigure = stdenv.lib.optionalString stdenv.hostPlatform.isLinux "export CFLAGS='-fgnu89-inline'";
37+
38+ postInstall = ''
39+ mkdir -p $out/lib $out/include
40+ cp libargp.a $out/lib
41+ cp argp.h $out/include
42+ '';
2943
3044 doCheck = true;
3145
@@ -34,8 +48,8 @@ stdenv.mkDerivation rec {
3448 meta = with stdenv.lib; {
3549 homepage = "https://www.lysator.liu.se/~nisse/misc/";
3650 description = "Standalone version of arguments parsing functions from GLIBC";
37− platforms = platforms.darwin;
51+ platforms = with platforms; darwin ++ [ "x86_64-linux" ];
3852 maintainers = with maintainers; [ amar1729 ];
39− license = stdenv.lib.licenses.gpl2;
53+ license = licenses.gpl2;
4054 };
4155}