about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/stfl/default.nix
blob: 845e815be5902e19f9c8957210f4d2da99b8d0d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{ lib, stdenv, fetchurl, ncurses, libiconv }:

stdenv.mkDerivation rec {
  pname = "stfl";
  version = "0.24";

  src = fetchurl {
    url = "http://www.clifford.at/stfl/stfl-${version}.tar.gz";
    sha256 = "1460d5lc780p3q38l3wc9jfr2a7zlyrcra0li65aynj738cam9yl";
  };

  makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ];

  buildInputs = [ ncurses libiconv ];

  preBuild = ''
    sed -i s/gcc/cc/g Makefile
    sed -i s%ncursesw/ncurses.h%ncurses.h% stfl_internals.h
  '' + lib.optionalString stdenv.isDarwin ''
    sed -i s/-soname/-install_name/ Makefile
  ''
  # upstream builds shared library unconditionally. Also, it has no
  # support for cross-compilation.
  + lib.optionalString stdenv.hostPlatform.isStatic ''
    sed -i 's/all:.*/all: libstfl.a stfl.pc/' Makefile
    sed -i 's/\tar /\t${stdenv.cc.targetPrefix}ar /' Makefile
    sed -i 's/\tranlib /\t${stdenv.cc.targetPrefix}ranlib /' Makefile
    sed -i '/install -m 644 libstfl.so./d' Makefile
    sed -i '/ln -fs libstfl.so./d' Makefile
  '' ;

  installPhase = ''
    DESTDIR=$out prefix=\"\" make install
  ''
  # some programs rely on libstfl.so.0 to be present, so link it
  + lib.optionalString (!stdenv.hostPlatform.isStatic) ''
    ln -s $out/lib/libstfl.so.0.24 $out/lib/libstfl.so.0
  '';

  meta = {
    homepage = "http://www.clifford.at/stfl/";
    description = "A library which implements a curses-based widget set for text terminals";
    maintainers = with lib.maintainers; [ lovek323 ];
    license = lib.licenses.lgpl3;
    platforms = lib.platforms.unix;
  };
}