ocamlPackages.ocamlgraph: make GTK support optional

When `gtkSupport` is true, additional components are built:

 - a module to render a graph on a GTK2 canvas
 - two GTK-based programs: a graph viewer and a graph editor.

The default is to have `gtkSupport` as it is used in e.g., Frama-C.
This commit is contained in:
Vincent Laporte 2020-08-22 07:55:58 +02:00 committed by Vincent Laporte
parent 5be356a9cc
commit e3c2934213
2 changed files with 14 additions and 27 deletions

View File

@ -1,4 +1,7 @@
{stdenv, fetchurl, ocaml, findlib, lablgtk ? null}:
{ stdenv, fetchurl, ocaml, findlib
, gtkSupport ? true
, lablgtk
}:
stdenv.mkDerivation rec {
pname = "ocamlgraph";
@ -9,22 +12,19 @@ stdenv.mkDerivation rec {
sha256 = "0m9g16wrrr86gw4fz2fazrh8nkqms0n863w7ndcvrmyafgxvxsnr";
};
buildInputs = [ ocaml findlib lablgtk ];
patches = ./destdir.patch;
postPatch = ''
sed -i 's@$(DESTDIR)$(OCAMLLIB)/ocamlgraph@$(DESTDIR)/lib/ocaml/${ocaml.version}/site-lib/ocamlgraph@' Makefile.in
sed -i 's@OCAMLFINDDEST := -destdir $(DESTDIR)@@' Makefile.in
${stdenv.lib.optionalString (lablgtk != null)
"sed -i 's@+lablgtk2@${lablgtk}/lib/ocaml/${ocaml.version}/site-lib/lablgtk2 -I ${lablgtk}/lib/ocaml/${ocaml.version}/site-lib/stublibs@' configure Makefile.in editor/Makefile"}
'';
buildInputs = [ ocaml findlib ]
++ stdenv.lib.optional gtkSupport lablgtk
;
createFindlibDestdir = true;
buildPhase = ''
make all
make install-findlib
buildFlags = [ "all" ];
installTargets = [ "install-findlib" ];
postInstall = stdenv.lib.optionalString gtkSupport ''
mkdir -p $out/bin
cp dgraph/dgraph.opt $out/bin/graph-viewer
cp editor/editor.opt $out/bin/graph-editor
'';
meta = {

View File

@ -1,13 +0,0 @@
diff -Naur -x '*~' ocamlgraph-1.8.1/Makefile.in ocamlgraph-1.8.1-new//Makefile.in
--- ocamlgraph-1.8.1/Makefile.in 2011-10-17 09:57:03.000000000 -0430
+++ ocamlgraph-1.8.1-new//Makefile.in 2011-11-24 13:01:22.626004819 -0430
@@ -16,8 +16,8 @@
##########################################################################
# Where to install the binaries
-DESTDIR =
prefix =@prefix@
+DESTDIR=$(prefix)
exec_prefix=@exec_prefix@
datarootdir=@datarootdir@
BINDIR =$(DESTDIR)@bindir@