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.
This commit is contained in:
Richard W.M. Jones 2019-11-15 13:49:03 +00:00
parent 5adc89253f
commit 1d80227c96

View File

@ -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