aa4be47
%global opt %(test -x %{_bindir}/ocamlopt && echo 1 || echo 0)
aa4be47
%if !%{opt}
aa4be47
%global debug_package %{nil}
aa4be47
%endif
aa4be47
aa4be47
Name:           ocaml-xmlm
aa4be47
Version:        1.2.0
6f1b4a5
Release:        3%{?dist}
aa4be47
Summary:        A streaming XML codec
aa4be47
aa4be47
License:        BSD
aa4be47
URL:            http://erratique.ch/software/xmlm
aa4be47
Source0:        http://erratique.ch/software/xmlm/releases/xmlm-%{version}.tbz
6f1b4a5
# Ensure source files are included in generated debuginfo subpackage
6f1b4a5
Patch0:         xmlm-1.2.0-debug.patch
aa4be47
# Example XML files for testing
aa4be47
Source1:        test-valid.xml
aa4be47
Source2:        test-invalid.xml
aa4be47
aa4be47
ExclusiveArch:  %{ocaml_arches}
aa4be47
aa4be47
BuildRequires:  ocaml >= 3.10.0
aa4be47
BuildRequires:  ocaml-findlib
aa4be47
aa4be47
%global libname %(sed -e 's/^ocaml-//' <<< %{name})
aa4be47
aa4be47
%description
aa4be47
Xmlm is an OCaml streaming codec to decode and encode the XML data
aa4be47
format. It can process XML documents without a complete in-memory
aa4be47
representation of the data.
aa4be47
aa4be47
aa4be47
%package        devel
aa4be47
Summary:        Development files for %{name}
aa4be47
Requires:       %{name}%{?_isa} = %{version}-%{release}
aa4be47
aa4be47
%description    devel
aa4be47
The %{name}-devel package contains libraries and signature files for
aa4be47
developing applications that use %{name}.
aa4be47
aa4be47
aa4be47
%prep
aa4be47
%setup -q -n %{libname}-%{version}
6f1b4a5
%patch0 -p1 -b .debug
aa4be47
aa4be47
aa4be47
%build
aa4be47
%if %{opt}
aa4be47
./pkg/build true
aa4be47
%else
aa4be47
./pkg/build false
aa4be47
%endif
aa4be47
aa4be47
aa4be47
%install
aa4be47
# These rules work if the library uses 'ocamlfind install' to install itself.
aa4be47
export DESTDIR=$RPM_BUILD_ROOT
aa4be47
export OCAMLFIND_DESTDIR=$RPM_BUILD_ROOT%{_libdir}/ocaml
aa4be47
mkdir -p $RPM_BUILD_ROOT%{_bindir}
aa4be47
mkdir -p $OCAMLFIND_DESTDIR/%{libname}
aa4be47
aa4be47
%if %{opt}
aa4be47
install -m 755 -p _build/test/xmltrip.native $RPM_BUILD_ROOT%{_bindir}/xmltrip
aa4be47
install -m 644 -p _build/src/xmlm.{a,cmxa} $OCAMLFIND_DESTDIR/%{libname}/
aa4be47
install -m 755 -p _build/src/xmlm.cmxs $OCAMLFIND_DESTDIR/%{libname}/
aa4be47
%else
aa4be47
install -m 755 -p _build/test/xmltrip.byte $RPM_BUILD_ROOT%{_bindir}/xmltrip
aa4be47
%endif
aa4be47
install -m 644 -p _build/pkg/META _build/src/xmlm.{cm?,mli} $OCAMLFIND_DESTDIR/%{libname}/
aa4be47
aa4be47
aa4be47
%check
aa4be47
# Against valid XML
aa4be47
$RPM_BUILD_ROOT%{_bindir}/xmltrip -p %{SOURCE1} 2>valid-err.log
aa4be47
[ -z "$(cat valid-err.log)" ]
aa4be47
aa4be47
# Against invalid XML - stderr should contain the word expected
aa4be47
$RPM_BUILD_ROOT%{_bindir}/xmltrip -p %{SOURCE2} 2>invalid-err.log
aa4be47
grep expected invalid-err.log >/dev/null
aa4be47
aa4be47
%files
aa4be47
# LICENSE not bundled
aa4be47
%doc README.md
aa4be47
%{_bindir}/xmltrip
aa4be47
%{_libdir}/ocaml/xmlm/
aa4be47
%if %opt
aa4be47
%exclude %{_libdir}/ocaml/*/*.a
aa4be47
%exclude %{_libdir}/ocaml/*/*.cmxa
aa4be47
%exclude %{_libdir}/ocaml/*/*.cmxs
aa4be47
%exclude %{_libdir}/ocaml/*/*.cmx
aa4be47
%endif
aa4be47
%exclude %{_libdir}/ocaml/*/*.mli
aa4be47
aa4be47
aa4be47
%files devel
aa4be47
# LICENSE not bundled
aa4be47
%doc CHANGES.md _build/test/examples.ml _build/test/xhtml.ml doc
aa4be47
%if %opt
aa4be47
%{_libdir}/ocaml/*/*.a
aa4be47
%{_libdir}/ocaml/*/*.cmxa
aa4be47
%{_libdir}/ocaml/*/*.cmxs
aa4be47
%{_libdir}/ocaml/*/*.cmx
aa4be47
%endif
aa4be47
%{_libdir}/ocaml/*/*.mli
aa4be47
aa4be47
aa4be47
%changelog
6f1b4a5
* Fri Feb 14 2014 Michel Salim <salimma@fedoraproject.org> - 1.2.0-3
6f1b4a5
- Include source files in -debuginfo
6f1b4a5
aa4be47
* Sat Feb  8 2014 Michel Salim <salimma@fedoraproject.org> - 1.2.0-2
aa4be47
- Incorporate review feedback
aa4be47
aa4be47
* Mon Jan 20 2014 Michel Salim <salimma@fedoraproject.org> - 1.2.0-1
aa4be47
- Initial package