Blob Blame History Raw
%ifnarch %{ocaml_native_compiler}
%global debug_package %{nil}

%global srcname uutf

Name:           ocaml-%{srcname}
Version:        1.0.2
Release:        1%{?dist}
Summary:        Non-blocking streaming Unicode codec for OCaml

License:        ISC
# The uchar package is a forward compatibility package for OCaml versions prior
# to 4.03.  We have a later OCaml in Fedora; uchar is in the standard library.
# Therefore, remove references to the compatibility package.
Patch0:         %{name}-uchar.patch

BuildRequires:  ocaml >= 4.01.0
BuildRequires:  ocaml-cmdliner-devel >= 0.9.6
BuildRequires:  ocaml-findlib
BuildRequires:  ocaml-ocamlbuild
BuildRequires:  ocaml-ocamldoc
BuildRequires:  ocaml-topkg-devel

Uutf is a non-blocking streaming codec to decode and encode the UTF-8,
UTF-16, UTF-16LE and UTF-16BE encoding schemes.  It can efficiently work
character by character without blocking on I/O.  Decoders perform
character position tracking and support newline normalization.

Functions are also provided to fold over the characters of UTF-encoded
OCaml string values and to directly encode characters in OCaml Buffer.t

%package        devel
Summary:        Development files for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description    devel
The %{name}-devel package contains libraries and signature files for
developing applications that use %{name}.

%autosetup -n %{srcname}-%{version} -p1

# Topkg does watermark replacements only if run inside a git checkout.  Github
# tarballs do not come with a .git directory.  Therefore, we do the watermark
# replacement manually.
for fil in $(find . -type f); do
  sed -e 's,%%%%NAME%%%%,%{srcname},' \
      -e 's,%%%%PKG_HOMEPAGE%%%%,%{url},' \
      -e 's,%%%%VERSION%%%%,v%{version},' \
      -e 's,%%%%VERSION_NUM%%%%,%{version},' \
      -i.orig $fil
  touch -r $fil.orig $fil
  rm $fil.orig

# Build the library and the tests
ocaml pkg/ build --tests true --with-cmdliner true

# Build the documentation
mkdir html
ocamldoc -html -d html -I _build/src _build/src/uutf.mli

# Install the library
mkdir -p %{buildroot}%{_libdir}/ocaml/uutf
cp -p _build/{opam,pkg/META} %{buildroot}%{_libdir}/ocaml/uutf
%ifarch %{ocaml_native_compiler}
cp -a _build/src/*.{a,cma,cmi,cmt,cmti,cmx,cmxa,cmxs,mli} \
cp -a _build/src/*.{cma,cmi,cmt,cmti,mli} %{buildroot}%{_libdir}/ocaml/uutf

ocaml pkg/ test

%dir %{_libdir}/ocaml/%{srcname}/
%ifarch %{ocaml_native_compiler}

%files devel
%doc html/*
%ifarch %{ocaml_native_compiler}

* Thu Jan  9 2020 Jerry James <> - 1.0.2-1
- Initial RPM