Name:       ocaml-vector3
Version:    0.2
Release:    %mkrel 1
Summary:    Module for 3D vectors
License:    BSD
# the _oasis file tells it's BSD-3-Clause
# but the header tells it's BSD-2-Clause
Group:      Development/OCaml
URL:        https://github.com/HappyCrow/vector3
Source0:    opam-vector3.%{version}.tar.bz2
Source1:    https://github.com/HappyCrow/vector3/archive/v%{version}.tar.gz
BuildRequires:  ocaml-findlib
BuildRequires:  opam

%description
Module for 3D vectors
(implemented as records of x, y and z floats).

%package    devel
Summary:    Development files for %{name}
Group:      Development/OCaml
Requires:   %{name} = %{version}-%{release}

%description devel
This package contains the development modules you need to use %{name} in
your programs.

%prep
%setup -q -n opam-vector3.%{version}
sed -i -e 's,@ARCHIVE@,%{SOURCE1},' \
  packages/vector3.%{version}/url
if [ -f $HOME/.opam ]; then exit 1; fi
opam init --no-setup
opam repo remove default
NR=`opam repo list | wc -l`
if [ $NR != "0" ]; then exit 1; fi
opam repo add mga-local .

%build
opam update

%install
rm -rf %{buildroot}
export DESTDIR=%{buildroot}
export OCAMLFIND_DESTDIR=%{buildroot}/%{_libdir}/ocaml
mkdir -p $OCAMLFIND_DESTDIR/vector3
opam install vector3

%files
%dir %{_libdir}/ocaml/vector3
%{_libdir}/ocaml/vector3/META
%{_libdir}/ocaml/vector3/*.cmi
%{_libdir}/ocaml/vector3/*.cma
%{_libdir}/ocaml/vector3/*.cmxs

%files devel
%{_libdir}/ocaml/vector3/*.a
%{_libdir}/ocaml/vector3/*.cmxa
%{_libdir}/ocaml/vector3/*.cmx
%{_libdir}/ocaml/vector3/*.mli