2021-02-05 17:12:51 +00:00
{ lib , stdenv , fetchurl , fetchpatch }:
2020-04-24 23:36:52 +00: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
stdenv . mkDerivation {
name = " a r g p - s t a n d a l o n e - 1 . 3 " ;
src = fetchurl {
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 - 1 . 3 . t a r . g z " ;
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 " ;
} ;
patches =
2021-02-05 17:12:51 +00:00
lib . optionals stdenv . hostPlatform . isDarwin [ patch-argp-fmtstream ]
++ lib . optionals stdenv . hostPlatform . isLinux [ patch-throw-in-funcdef patch-shared ] ;
2020-04-24 23:36:52 +00:00
2021-02-05 17:12:51 +00:00
patchFlags = lib . optional stdenv . hostPlatform . isDarwin " - p 0 " ;
2020-04-24 23:36:52 +00:00
2021-07-17 21:14:59 +00: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 ' " ;
2020-04-24 23:36:52 +00:00
postInstall = ''
mkdir - p $ out/lib $ out/include
cp libargp . a $ out/lib
cp argp . h $ out/include
'' ;
doCheck = true ;
makeFlags = [ " A R : = $ ( A R ) " ] ;
enableParallelBuilding = true ;
2021-02-05 17:12:51 +00:00
meta = with lib ; {
2020-04-24 23:36:52 +00: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-18 16:06:22 +00:00
platforms = with platforms ; darwin ++ linux ;
2020-04-24 23:36:52 +00:00
maintainers = with maintainers ; [ amar1729 ] ;
license = licenses . gpl2 ;
} ;
}