1{ lib, stdenv, fetchFromGitHub
2, bmake
3}:
4
5stdenv.mkDerivation rec {
6 pname = "libfsm";
7 version = "0.1pre2442_${builtins.substring 0 8 src.rev}";
8
9 src = fetchFromGitHub {
10 owner = "katef";
11 repo = pname;
12 rev = "9c5095f7364fa464efff6c81fad9b60b19dfcc99";
13 sha256 = "1bs51agvrrwqid0slq2svj2yj7kkjdsnv3xsrk8zmf1jbgza6jrm";
14 fetchSubmodules = true;
15 };
16
17 nativeBuildInputs = [ bmake ];
18 enableParallelBuilding = true;
19
20 # note: build checks value of '$CC' to add some extra cflags, but we don't
21 # necessarily know which 'stdenv' someone chose, so we leave it alone (e.g.
22 # if we use stdenv vs clangStdenv, we don't know which, and CC=cc in all
23 # cases.) it's unclear exactly what should be done if we want those flags,
24 # but the defaults work fine.
25 makeFlags = [ "-r" "PREFIX=$(out)" ];
26
27 # fix up multi-output install. we also have to fix the pkg-config libdir
28 # file; it uses prefix=$out; libdir=${prefix}/lib, which is wrong in
29 # our case; libdir should really be set to the $lib output.
30 postInstall = ''
31 mkdir -p $lib $dev/lib
32
33 mv $out/lib $lib/lib
34 mv $out/include $dev/include
35 mv $out/share/pkgconfig $dev/lib/pkgconfig
36 rmdir $out/share
37
38 for x in libfsm.pc libre.pc; do
39 substituteInPlace "$dev/lib/pkgconfig/$x" \
40 --replace 'libdir=''${prefix}/lib' "libdir=$lib/lib"
41 done
42 '';
43
44 outputs = [ "out" "lib" "dev" ];
45
46 meta = with lib; {
47 description = "DFA regular expression library & friends";
48 homepage = "https://github.com/katef/libfsm";
49 license = licenses.bsd2;
50 platforms = platforms.unix;
51 maintainers = with maintainers; [ thoughtpolice ];
52 };
53}