1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 autoreconfHook,
7 enableStatic ? stdenv.hostPlatform.isStatic,
8 enableShared ? !stdenv.hostPlatform.isStatic,
9}:
10
11stdenv.mkDerivation rec {
12 pname = "termcap";
13 version = "1.3.1";
14
15 src = fetchurl {
16 url = "mirror://gnu/termcap/termcap-${version}.tar.gz";
17 hash = "sha256-kaDiLlOHykRntbyxjt8cUbkwJi/UZtX9o5bdnSZxkQA=";
18 };
19
20 patches = [
21 (fetchpatch {
22 name = "0001-tparam-replace-write-with-fprintf.patch";
23 url = "https://github.com/msys2/MINGW-packages/raw/c6691ad1bd9d4c6823a18068ca0683c3e32ea005/mingw-w64-termcap/0001-tparam-replace-write-with-fprintf.patch";
24 hash = "sha256-R9XaLfa8fzQBt+M+uA1AFTvKYCeOWLUD/7GViazXwto=";
25 })
26 ];
27
28 outputs = [
29 "out"
30 "dev"
31 ];
32
33 enableParallelBuilding = true;
34
35 strictDeps = true;
36
37 nativeBuildInputs = [ autoreconfHook ];
38
39 makeFlags = [
40 "AR=${stdenv.cc.targetPrefix}ar"
41 ];
42
43 env.NIX_CFLAGS_COMPILE = toString (
44 [
45 "-DSTDC_HEADERS"
46 ]
47 ++ lib.optionals stdenv.cc.isClang [
48 "-Wno-implicit-function-declaration"
49 ]
50 );
51
52 # Library only statically links by default
53 postInstall =
54 lib.optionalString (!enableStatic) ''
55 rm $out/lib/libtermcap.a
56 ''
57 + lib.optionalString enableShared (
58 let
59 libName = "libtermcap${stdenv.hostPlatform.extensions.sharedLibrary}";
60 impLibName = "libtermcap.dll.a";
61 winImpLib = lib.optionalString stdenv.hostPlatform.isWindows "-Wl,--out-implib,${impLibName}";
62 in
63 ''
64 ${stdenv.cc.targetPrefix}cc -shared -o ${libName} termcap.o tparam.o version.o ${winImpLib}
65 install -Dm644 ${libName} $out/lib
66 ''
67 + lib.optionalString stdenv.hostPlatform.isWindows ''
68 install -Dm644 ${impLibName} $out/lib
69 ''
70 );
71
72 meta = {
73 description = "Terminal feature database";
74 homepage = "https://www.gnu.org/software/termutils/";
75 license = lib.licenses.gpl2Plus;
76 maintainers = with lib.maintainers; [ wegank ];
77 platforms = lib.platforms.all;
78 };
79}