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