about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/libfsm/default.nix
blob: 5491fab3edf22e5a8d654d1001dadb898e5c8d6a (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
{ stdenv, fetchFromGitHub
, bmake
}:

stdenv.mkDerivation rec {
  name    = "libfsm-${version}";
  version = "0.1pre1869_${builtins.substring 0 7 src.rev}";

  src = fetchFromGitHub {
    owner  = "katef";
    repo   = "libfsm";
    rev    = "f70c3c5778a79eeecb52f9fd35c7cbc241db0ed6";
    sha256 = "1hgv272jdv6dwnsdjajyky537z84q0cwzspw9br46qj51h8gkwvx";
    fetchSubmodules = true;
  };

  nativeBuildInputs = [ bmake ];
  enableParallelBuilding = true;

  # note: build checks value of '$CC' to add some extra cflags, but we don't
  # necessarily know which 'stdenv' someone chose, so we leave it alone (e.g.
  # if we use stdenv vs clangStdenv, we don't know which, and CC=cc in all
  # cases.) it's unclear exactly what should be done if we want those flags,
  # but the defaults work fine.
  buildPhase = "PREFIX=$out bmake -r install";

  # fix up multi-output install. we also have to fix the pkgconfig libdir
  # file; it uses prefix=$out; libdir=${prefix}/lib, which is wrong in
  # our case; libdir should really be set to the $lib output.
  installPhase = ''
    mkdir -p $lib $dev/lib

    mv $out/lib             $lib/lib
    mv $out/include         $dev/include
    mv $out/share/pkgconfig $dev/lib/pkgconfig
    rmdir $out/share

    for x in libfsm.pc libre.pc; do
      substituteInPlace "$dev/lib/pkgconfig/$x" \
        --replace 'libdir=''${prefix}/lib' "libdir=$lib/lib"
    done
  '';

  outputs = [ "out" "lib" "dev" ];

  meta = with stdenv.lib; {
    description = "DFA regular expression library & friends";
    homepage    = "https://github.com/katef/libfsm";
    license     = licenses.bsd2;
    platforms   = platforms.unix;
    maintainers = with maintainers; [ thoughtpolice ];
  };
}