%define pkg_name    cpdf
%define pkg_version 2.3
# %define patchlevel  1
%define pkg_release 1%{?_dist_release}

Summary: Command Line Tools allow you to manipulate existing PDF files
Name:    %{pkg_name}
Version: %{pkg_version}
# Version: %{pkg_version}.p%{patchlevel}
Release: %{pkg_release}

License: Coherent Graphics Ltd Non-Commercial Use License Agreement
Group:   Applications/Publishing
URL:     http://community.coherentpdf.com/

Source0: cpdf-source-%{pkg_version}.tar.gz
# Source0: cpdf-source-%{pkg_version}-patchlevel%{patchlevel}.tar.gz

BuildRequires: readline-devel
BuildRequires: ocaml
BuildRequires: ocaml-findlib
BuildRequires: ocaml-camlpdf = %{pkg_version}

Vendor: Project Vine
Distribution: Vine Linux


%description
The Coherent PDF Command Line Tools allow you to manipulate
existing PDF files in a variety of ways.
For example:
 - Merge PDF files together, or split them apart Encrypt and decrypt
 - Scale, crop and rotate pages
 - Read and set document info and metadata
 - Copy, add or remove bookmarks
 - Stamp logos, text, dates, page numbers
 - Add or remove attachments
 - Losslessly compress PDF files

[caution]
Now we're releasing them for free, under a special not-for-commercial-use
license If you like the tools and want to use them commercially,
or need support, licenses are available from Coherent Graphics Ltd.
#'

%description -l ja
Coherent PDF は PDF ファイルを操作するためのコマンドラインツールです。

[注意1]
このアプリケーションは「非商用に限り」フリーで使用できます。
詳しくは LICENCE を参照して下さい。

%package libs
Summary: OCaml library for Coherent PDF
Group:   Development/Languages
Requires: ocaml
Requires: ocaml-findlib
Requires: ocaml-camlpdf = %{pkg_version}

%description libs
%{summary}


%prep
%{__rm} -rf ${RPM_BUILD_ROOT}
%setup -q -n %{name}-source-%{pkg_version}
# %setup -q -n %{name}-source-%{pkg_version}-patchlevel%{patchlevel}

%build
LDFLAGS="-ltinfo" %{__make}

%install
# for binary
%{__mkdir_p} ${RPM_BUILD_ROOT}%{_bindir}
%{__mkdir_p} ${RPM_BUILD_ROOT}%{_mandir}/man1
%{__cp} cpdf ${RPM_BUILD_ROOT}%{_bindir}
%{__cp} cpdf.1 ${RPM_BUILD_ROOT}%{_mandir}/man1

# for libs
INSTALLDIR=${RPM_BUILD_ROOT}%{_libdir}/ocaml
%{__mkdir_p} ${INSTALLDIR}
%{__make} install \
 OCAMLFIND_INSTFLAGS="-destdir ${INSTALLDIR}"

%clean
%{__rm} -rf ${RPM_BUILD_ROOT}

%post libs
echo "%{_libdir}/ocaml/%{pkg_name}" >> %{_libdir}/ocaml/ld.conf

%preun libs
%{__perl} -pi -e "s|^%{_libdir}/ocaml/%{pkg_name}\n$||" \
 %{_libdir}/ocaml/ld.conf


%files
%doc doc/cpdf/html
%doc Changes LICENSE cpdfmanual.pdf
%{_bindir}/cpdf
%{_mandir}/man1/*

%files libs
%{_libdir}/ocaml/cpdf


%changelog
* Sun Oct 06 2019 Toshiaki Ara <ara_t@384.jp> 2.3-1
- update to 2.3

* Sun Apr 15 2018 Toshiaki Ara <ara_t@384.jp> 2.2-pachlevel1
- initial build for Vine Linux

