2021-01-21 18:00:13 +01:00
{ lib , stdenv , fetchurl , fetchpatch }:
2018-10-20 07:52:11 +02:00
2018-12-19 00:29:28 +01:00
let
patch-argp-fmtstream = fetchpatch {
name = " p a t c h - a r g p - f m t s t r e a m . h " ;
url = " h t t p s : / / r a w . g i t h u b u s e r c o n t e n t . c o m / H o m e b r e w / f o r m u l a - p a t c h e s / b 5 f 0 a d 3 / a r g p - s t a n d a l o n e / p a t c h - a r g p - f m t s t r e a m . h " ;
sha256 = " 5 6 5 6 2 7 3 f 6 2 2 f d b 7 c a 7 c f 1 f 9 8 c 0 c 9 5 2 9 b e d 4 6 1 d 2 3 7 1 8 b c 2 a 6 a 8 5 9 8 6 e 4 f 8 e d 1 c b 8 " ;
} ;
patch-throw-in-funcdef = fetchpatch {
name = " a r g p - s t a n d a l o n e - 1 . 3 - t h r o w - i n - f u n c d e f . p a t c h " ;
url = " h t t p s : / / g i t w e b . g e n t o o . o r g / r e p o / g e n t o o . g i t / p l a i n / s y s - l i b s / a r g p - s t a n d a l o n e / f i l e s / a r g p - s t a n d a l o n e - 1 . 3 - t h r o w - i n - f u n c d e f . p a t c h ? i d = 4 0 9 d 0 e 2 a 9 c 9 c 8 9 9 f b 1 f b 0 4 c c 8 0 8 f e 0 a f f 3 f 7 4 5 c a " ;
sha256 = " 0 b 2 b 4 l 1 j k v m n f f l 2 2 j c n 4 y d z x y 2 i 7 f n m m n f i m 1 2 f 0 y g 5 p b 8 f s 4 3 c " ;
} ;
patch-shared = fetchpatch {
name = " a r g p - s t a n d a l o n e - 1 . 3 - s h a r e d . p a t c h " ;
url = " h t t p s : / / g i t w e b . g e n t o o . o r g / r e p o / g e n t o o . g i t / p l a i n / s y s - l i b s / a r g p - s t a n d a l o n e / f i l e s / a r g p - s t a n d a l o n e - 1 . 3 - s h a r e d . p a t c h ? i d = 4 0 9 d 0 e 2 a 9 c 9 c 8 9 9 f b 1 f b 0 4 c c 8 0 8 f e 0 a f f 3 f 7 4 5 c a " ;
sha256 = " 1 x x 2 z d c 1 8 7 a 1 m 2 x 6 c 1 q s 6 2 v c r y c b y c w 7 n 0 q 3 k s 2 z k x p a q z x 2 d g k w " ;
} ;
in
2021-06-22 15:21:29 +02:00
stdenv . mkDerivation rec {
pname = " a r g p - s t a n d a l o n e " ;
version = " 1 . 3 " ;
2018-10-20 07:52:11 +02:00
src = fetchurl {
2021-06-22 15:21:29 +02:00
url = " h t t p s : / / w w w . l y s a t o r . l i u . s e / ~ n i s s e / m i s c / a r g p - s t a n d a l o n e - ${ version } . t a r . g z " ;
2018-10-20 07:52:11 +02:00
sha256 = " d e c 7 9 6 9 4 d a 1 3 1 9 a c d 2 2 3 8 c e 9 5 d f 5 7 f 3 6 8 0 f e a 2 4 8 2 0 9 6 e 4 8 3 3 2 3 f d d f 3 d 8 1 8 d 8 b e " ;
} ;
2018-12-19 00:29:28 +01:00
patches =
2021-01-21 18:00:13 +01:00
lib . optionals stdenv . hostPlatform . isDarwin [ patch-argp-fmtstream ]
++ lib . optionals stdenv . hostPlatform . isLinux [ patch-throw-in-funcdef patch-shared ] ;
2018-12-19 00:29:28 +01:00
2021-01-21 18:00:13 +01:00
patchFlags = lib . optional stdenv . hostPlatform . isDarwin " - p 0 " ;
2018-12-19 00:29:28 +01:00
2021-07-05 01:56:19 +02:00
# For currently unknown reason, `-fPIC` has to be passed explicitly, otherwise
# downstream software like `elfutils` will get `recompile errors like:
# libargp.a(argp-help.o): relocation R_X86_64_PC32 against symbol `program_invocation_short_name' can not be used when making a shared object; recompile with -fPIC
# It seems that nixpkgs's on-by-default `-fPIC` is not in effect here.
preConfigure = lib . optionalString stdenv . hostPlatform . isLinux " e x p o r t C F L A G S = ' - f g n u 8 9 - i n l i n e - f P I C ' " ;
2018-12-19 00:29:28 +01:00
postInstall = ''
mkdir - p $ out/lib $ out/include
cp libargp . a $ out/lib
cp argp . h $ out/include
'' ;
2018-10-20 07:52:11 +02:00
doCheck = true ;
2019-11-13 00:54:59 +01:00
makeFlags = [ " A R : = $ ( A R ) " ] ;
2018-10-20 07:52:11 +02:00
enableParallelBuilding = true ;
2021-01-21 18:00:13 +01:00
meta = with lib ; {
2018-10-20 07:52:11 +02:00
homepage = " h t t p s : / / w w w . l y s a t o r . l i u . s e / ~ n i s s e / m i s c / " ;
description = " S t a n d a l o n e v e r s i o n o f a r g u m e n t s p a r s i n g f u n c t i o n s f r o m G L I B C " ;
2020-07-06 07:50:55 +02:00
platforms = with platforms ; darwin ++ linux ;
2018-10-20 07:52:11 +02:00
maintainers = with maintainers ; [ amar1729 ] ;
2018-12-19 00:29:28 +01:00
license = licenses . gpl2 ;
2018-10-20 07:52:11 +02:00
} ;
}