ocaml cairo

Richard W.M. Jones rjones at redhat.com
Thu Mar 19 10:40:55 UTC 2015


On Thu, Mar 19, 2015 at 08:50:49AM +0000, Richard W.M. Jones wrote:
> So I believe in this case, unless anyone objects, we should simply
> replace the upstream of the ocaml-cairo package with
> https://github.com/Chris00/ocaml-cairo
> 
> I _don't_ think we need to rename the package nor create a new
> ocaml-cairo2 package, because (a) only OPAM is using the "cairo2" name
> and (b) it's going to confuse the heck out of everyone because they'll
> think cairo itself has been rewritten.

There was a small, surmountable problem with this plan, which is that
the new ocaml-cairo uses a very crackpot build system (even by the low
standards of OCaml projects in general).

However I did manage to build it -- see attached proposed patch to
ocaml-cairo.spec.

I am able to build and run the examples using the proposed package,
eg:

$ ocamlfind ocamlopt -package cairo -linkpkg arcs.ml -o arcs
$ ocamlfind ocamlopt -package cairo.gtk2 -linkpkg gtk_demo.ml -o gtk_demo

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
-------------- next part --------------
>From b9cb8a7cef3c3675ce72a221bcfe92d3347f0a7e Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones at redhat.com>
Date: Thu, 19 Mar 2015 09:52:39 +0000
Subject: [PATCH] Switch bindings to https://github.com/Chris00/ocaml-cairo

- See: https://lists.fedoraproject.org/pipermail/devel/2015-March/209182.html
---
 .gitignore                                    |   1 +
 cairo-ocaml-1.0.0-bigarray.patch              |  12 ---
 ocaml-cairo-1.2.0-enable-ocamlopt-debug.patch |  14 ----
 ocaml-cairo-META                              |  12 +--
 ocaml-cairo.spec                              | 104 ++++++++++++++++----------
 sources                                       |   2 +-
 6 files changed, 74 insertions(+), 71 deletions(-)
 delete mode 100644 cairo-ocaml-1.0.0-bigarray.patch
 delete mode 100644 ocaml-cairo-1.2.0-enable-ocamlopt-debug.patch

diff --git a/.gitignore b/.gitignore
index 0dd833c..e4c1a48 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 ocaml-cairo-1.2.0-gita5c5ee9f.tar.gz
 /ocaml-cairo-1.2.0-git08b40192975.tar.gz
 /ocaml-cairo-1.2.0-git872c9bc92e6.tar.gz
+/ocaml-cairo-5c1df1516ad99bde444bf5717801e7df75252a6c.tar.gz
diff --git a/cairo-ocaml-1.0.0-bigarray.patch b/cairo-ocaml-1.0.0-bigarray.patch
deleted file mode 100644
index c0afb8a..0000000
--- a/cairo-ocaml-1.0.0-bigarray.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -ur cairo-ocaml-1.0.0.orig/src/ml_cairo_bigarr.c cairo-ocaml-1.0.0.compat/src/ml_cairo_bigarr.c
---- cairo-ocaml-1.0.0.orig/src/ml_cairo_bigarr.c	2009-06-18 19:01:26.000000000 +0100
-+++ cairo-ocaml-1.0.0.compat/src/ml_cairo_bigarr.c	2009-10-08 12:46:54.795555155 +0100
-@@ -9,6 +9,8 @@
- #include "ml_cairo.h"
- 
- #include <caml/bigarray.h>
-+#undef CAML_NAME_SPACE
-+#include <caml/compatibility.h>
- 
- unsigned long bigarray_byte_size (struct caml_bigarray *);
- 
diff --git a/ocaml-cairo-1.2.0-enable-ocamlopt-debug.patch b/ocaml-cairo-1.2.0-enable-ocamlopt-debug.patch
deleted file mode 100644
index 832081e..0000000
--- a/ocaml-cairo-1.2.0-enable-ocamlopt-debug.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- ocaml-cairo-1.2.0/Makefile.rules~	2011-09-11 16:09:06.000000000 +0100
-+++ ocaml-cairo-1.2.0/Makefile.rules	2013-09-14 14:51:18.682632883 +0100
-@@ -1,8 +1,8 @@
- %.cmo : %.ml
--	$(OCAMLC) -c $(INCFLAGS) $<
-+	$(OCAMLC) -g -c $(INCFLAGS) $<
- %.cmx : %.ml
--	$(OCAMLOPT) -c $(INCFLAGS) $<
-+	$(OCAMLOPT) -g -c $(INCFLAGS) $<
- %.cmi : %.mli
--	$(OCAMLC) $(INCFLAGS) $<
-+	$(OCAMLC) -g $(INCFLAGS) $<
- %.o : %.c
- 	$(OCAMLC) -ccopt "$(CPPFLAGS)" $<
diff --git a/ocaml-cairo-META b/ocaml-cairo-META
index 19acb8d..80c5107 100644
--- a/ocaml-cairo-META
+++ b/ocaml-cairo-META
@@ -1,11 +1,11 @@
-name = "cairo-ocaml"
+name = "cairo"
 description = "Bindings to the cairo library."
-archive(byte) = "cairo.cma"
-archive(native) = "cairo.cmxa"
+archive(byte) = "cairo2.cma"
+archive(native) = "cairo2.cmxa"
 requires = "bigarray"
 
-package "lablgtk2" (
+package "gtk2" (
         requires = "cairo lablgtk2"
-        archive(byte) = "cairo_lablgtk.cma"
-        archive(native) = "cairo_lablgtk.cmxa"
+        archive(byte) = "cairo_gtk.cma"
+        archive(native) = "cairo_gtk.cmxa"
 )
diff --git a/ocaml-cairo.spec b/ocaml-cairo.spec
index 76454fd..ba1b5a4 100644
--- a/ocaml-cairo.spec
+++ b/ocaml-cairo.spec
@@ -1,42 +1,41 @@
-%global opt %(test -x %{_bindir}/ocamlopt && echo 1 || echo 0)
+%ifarch %{ocaml_native_compiler}
+%global native_compiler 1
+%else
+%global native_compiler 0
+%endif
 
-# Important note!  There are at least two quite separate OCaml cairo
-# projects.  This one is: http://cairographics.org/cairo-ocaml/
-# The other one is: http://forge.ocamlcore.org/projects/cairo/
-
-# There are no source releases for ocaml-cairo > 1.0.0.  To get the
-# source matching this you have to do:
+# Important note!
+# There are at least two quite separate OCaml cairo projects.
+#
+# This is (packaged in Fedora >= 23):
+#   http://forge.ocamlcore.org/projects/cairo/
+#   https://github.com/Chris00/ocaml-cairo
 #
-# git clone git://anongit.freedesktop.org/cairo-ocaml
-# cd cairo-ocaml
-# git archive --prefix=ocaml-cairo-%{version}/ %{commit} | \
-#   gzip > ../ocaml-cairo-1.2.0-git%{commit}.tar.gz
-%global commit 872c9bc92e6
+# The other one (which used to be packaged in Fedora <= 22) is:
+#   http://cairographics.org/cairo-ocaml/
+
+# Packaging git pre-releases here.
+%global commit 5c1df1516ad99bde444bf5717801e7df75252a6c
+%global shortcommit %(c=%{commit}; echo ${c:0:7})
 
 Name:           ocaml-cairo
-Epoch:          1
-Version:        1.2.0
-Release:        0.20.git%{commit}%{?dist}
+Epoch:          2
+Version:        0.4.7
+Release:        0.1.git%{shortcommit}%{?dist}
 Summary:        OCaml library for accessing cairo graphics
 
-ExcludeArch:    sparc64 s390 s390x
+License:        LGPLv3+
+URL:            https://github.com/Chris00/%{name}
 
-License:        LGPLv2
-URL:            http://cairographics.org/cairo-ocaml/
-
-Source0:        ocaml-cairo-%{version}-git%{commit}.tar.gz
+Source0:        https://github.com/Chris00/%{name}/archive/%{commit}/%{name}-%{commit}.tar.gz
 Source1:        ocaml-cairo-META
 
-Patch1:         ocaml-cairo-1.2.0-enable-ocamlopt-debug.patch
-
 BuildRequires:  ocaml >= 3.10.0
 BuildRequires:  ocaml-findlib-devel
 BuildRequires:  ocaml-ocamldoc
 BuildRequires:  ocaml-lablgtk-devel
 BuildRequires:  cairo-devel >= 1.2.0
-BuildRequires:  automake
 BuildRequires:  gtk2-devel
-BuildRequires:  chrpath
 
 
 %description
@@ -53,6 +52,8 @@ significant addition of translucence in the imaging model). When
 complete, the API is intended to support the complete imaging model of
 PDF 1.4.
 
+This package contains OCaml bindings for Cairo.
+
 
 %package        devel
 Summary:        Development files for %{name}
@@ -66,19 +67,44 @@ developing applications that use %{name}.
 
 
 %prep
-%setup -q
+%setup -q -n %{name}-%{commit}
 
-%patch1 -p1
-
-aclocal -I support
-autoconf
-./configure --libdir=%{_libdir}
 cp %{SOURCE1} META
 
 
 %build
-make
-make doc
+# The upstream package uses some crackpot build system which is
+# not supported in Fedora.  Just build the files by hand instead.
+pushd src
+
+# OCaml files.
+ocamlfind ocamlc -package lablgtk2 -g -c cairo.mli
+ocamlfind ocamlc -package lablgtk2 -g -c cairo.ml
+ocamlfind ocamlc -package lablgtk2 -g -c cairo_gtk.mli
+ocamlfind ocamlc -package lablgtk2 -g -c cairo_gtk.ml
+%if %{native_compiler}
+ocamlfind ocamlopt -package lablgtk2 -g -c cairo.ml
+ocamlfind ocamlopt -package lablgtk2 -g -c cairo_gtk.ml
+%endif
+
+# C files.
+CFLAGS="%{optflags} -fPIC `pkg-config gtk+-2.0 --cflags` -I%{_libdir}/ocaml -I%{_libdir}/ocaml/lablgtk2"
+gcc $CFLAGS -c cairo_stubs.c
+gcc $CFLAGS -c cairo_gtk_stubs.c
+
+# Build the two libraries, twice (bytecode & native).
+ocamlfind ocamlmklib -o cairo2 cairo_stubs.o cairo.cmo \
+          `pkg-config gtk+-2.0 --libs`
+ocamlfind ocamlmklib -o cairo_gtk cairo_gtk_stubs.o cairo_gtk.cmo \
+          `pkg-config gtk+-2.0 --libs`
+%if %{native_compiler}
+ocamlfind ocamlmklib -o cairo2 cairo_stubs.o cairo.cmx \
+          `pkg-config gtk+-2.0 --libs`
+ocamlfind ocamlmklib -o cairo_gtk cairo_gtk_stubs.o cairo_gtk.cmx \
+          `pkg-config gtk+-2.0 --libs`
+%endif
+
+popd
 
 
 %install
@@ -88,13 +114,10 @@ mkdir -p $OCAMLFIND_DESTDIR $OCAMLFIND_DESTDIR/stublibs
 
 ocamlfind install cairo src/{*.mli,*.cmi,*.cma,*.a,*.cmxa,*.cmx,dll*.so} META
 
-chrpath --delete $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs/dll*.so
-
 
 %files
-%doc COPYING
 %{_libdir}/ocaml/cairo
-%if %opt
+%if %{native_compiler}
 %exclude %{_libdir}/ocaml/cairo/*.a
 %exclude %{_libdir}/ocaml/cairo/*.cmxa
 %exclude %{_libdir}/ocaml/cairo/*.cmx
@@ -105,8 +128,9 @@ chrpath --delete $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs/dll*.so
 
 
 %files devel
-%doc COPYING ChangeLog README doc/html
-%if %opt
+# XXX The tutorial doesn't build.
+%doc examples
+%if %{native_compiler}
 %{_libdir}/ocaml/cairo/*.a
 %{_libdir}/ocaml/cairo/*.cmxa
 %{_libdir}/ocaml/cairo/*.cmx
@@ -115,6 +139,10 @@ chrpath --delete $RPM_BUILD_ROOT%{_libdir}/ocaml/stublibs/dll*.so
 
 
 %changelog
+* Thu Mar 19 2015 Richard W.M. Jones <rjones at redhat.com> - 2:0.4.7-0.1.git5c1df15
+- Switch bindings to https://github.com/Chris00/ocaml-cairo
+- See: https://lists.fedoraproject.org/pipermail/devel/2015-March/209182.html
+
 * Tue Feb 17 2015 Richard W.M. Jones <rjones at redhat.com> - 1:1.2.0-0.20.git872c9bc92e6
 - ocaml-4.02.1 rebuild.
 
diff --git a/sources b/sources
index 9e53149..a507a69 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-4d47096f08fa069f88e4161b9cf4d693  ocaml-cairo-1.2.0-git872c9bc92e6.tar.gz
+5119bd2096b310613c7fe082c84dab15  ocaml-cairo-5c1df1516ad99bde444bf5717801e7df75252a6c.tar.gz
-- 
2.3.1



More information about the devel mailing list