summary refs log tree commit diff
path: root/pkgs/development/interpreters/tclreadline/default.nix
blob: bbd34f71d22d6418ba00a54a1ca7182c61ecca1b (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{ stdenv
, fetchFromGitHub
, automake
, autoconf
, libtool
, readline
, tcl
, tk
}:

stdenv.mkDerivation rec {
  pname = "tclreadline";
  version = "2.3.8";

  src = fetchFromGitHub {
    owner = "flightaware";
    repo = "tclreadline";
    rev = "v${version}";
    sha256 = "18jl56p0hwgynxpvr0v7b5mvvzc1m64fn61c0957bgb45mc250yq";
  };

  nativeBuildInputs = [
    automake
    autoconf
    libtool
  ];
  buildInputs = [
    readline
    tcl
    tk
  ];

  preConfigure = "NOCONFIGURE=1 ./autogen.sh";

  configureFlags = [
    "--enable-tclshrl"
    "--enable-wishrl"
    "--with-tcl=${tcl}/lib"
    "--with-tk=${tk}/lib"
    "--with-readline-includes=${readline.dev}/include/readline"
    "--with-libtool=${libtool}"
  ];

  # The provided makefile leaves a wrong reference to /build/ in RPATH,
  # so we fix it after checking that everything is also present in $out
  preFixup = stdenv.lib.optionalString stdenv.isLinux ''
    needed_libraries=$(ls .libs | grep '\.\(so\|la\)$')
    for lib in $needed_libraries; do
      if ! ls $out/lib | grep "$lib"; then
        echo "$lib was not installed correctly"
        exit 1
      fi
    done
    for executable in $out/bin/{wishrl,tclshrl}; do
      patchelf --set-rpath \
        "$(patchelf --print-rpath "$executable" | sed "s@$builddir/.libs@$out/lib@")" \
        "$executable"
    done
  '';

  meta = with stdenv.lib; {
    description = "GNU readline for interactive tcl shells";
    homepage = "https://github.com/flightaware/tclreadline";
    license = licenses.bsd3;
    maintainers = with maintainers; [ fgaz ];
    platforms = platforms.all;
  };
}