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