From 1d80227c9618d0aa25693110119ddea4fba6d2ed Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 15 Nov 2019 13:49:03 +0000 Subject: [PATCH] Define have_ocaml macro. Use it in place of %{ocaml_native_compiler}. Use --disable-ocaml on non-OCaml platforms. Make the example.ml file conditional. --- nbdkit.spec | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/nbdkit.spec b/nbdkit.spec index c04f96a..214e0db 100644 --- a/nbdkit.spec +++ b/nbdkit.spec @@ -4,6 +4,12 @@ %global have_libguestfs 1 %endif +# We can only compiler the OCaml plugin on platforms which have native +# OCaml support (not bytecode). +%ifarch %{ocaml_native_compiler} +%global have_ocaml 1 +%endif + # Architectures where the complete test suite must pass. # # On all other architectures, a simpler test suite must pass. This @@ -72,7 +78,7 @@ BuildRequires: bash-completion BuildRequires: perl-devel BuildRequires: perl(ExtUtils::Embed) BuildRequires: python3-devel -%ifarch %{ocaml_native_compiler} +%if 0%{?have_ocaml} # Requires OCaml 4.02.2 which contains fix for # http://caml.inria.fr/mantis/view.php?id=6693 BuildRequires: ocaml >= 4.02.2 @@ -316,7 +322,7 @@ This package lets you forward NBD connections from %{name} to another NBD server. -%ifarch %{ocaml_native_compiler} +%if 0%{?have_ocaml} %package ocaml-plugin Summary: OCaml plugin for %{name} License: BSD @@ -564,6 +570,11 @@ autoreconf -i %configure \ PYTHON=%{_bindir}/python3 \ --disable-static \ +%if 0%{?have_ocaml} + --enable-ocaml \ +%else + --disable-ocaml \ +%endif %if 0%{?have_libguestfs} --with-libguestfs \ %else @@ -613,7 +624,7 @@ make %{?_smp_mflags} check || { } -%ifarch %{ocaml_native_compiler} +%if 0%{?have_ocaml} %ldconfig_scriptlets plugin-ocaml %endif @@ -745,7 +756,7 @@ make %{?_smp_mflags} check || { %{_mandir}/man1/nbdkit-nbd-plugin.1* -%ifarch %{ocaml_native_compiler} +%if 0%{?have_ocaml} %files ocaml-plugin %doc README %license LICENSE @@ -866,7 +877,9 @@ make %{?_smp_mflags} check || { %doc plugins/example*/*.c %doc plugins/example4/nbdkit-example4-plugin %doc plugins/lua/example.lua +%if 0%{?have_ocaml} %doc plugins/ocaml/example.ml +%endif %doc plugins/perl/example.pl %doc plugins/python/example.py %doc plugins/ruby/example.rb