%define binding_langs perl python

Summary: Portable C library for dynamically generating PDF files
Summary(ja): PDF ファイルを動的に生成できる取扱い易い C 言語ライブラリ
Name: pdflib-lite
Version: 7.0.5
Release: 3%{?_dist_release}
License: Distributable
Group: System Environment/Libraries
URL: http://www.pdflib.com/

Source: http://www.pdflib.com/binaries/PDFlib/705/PDFlib-Lite-%{version}p3.tar.gz

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: perl
BuildRequires: python-devel

Vendor: Project Vine
Distribution: Vine Linux
Conflicts: pdflib <= 4

%description
PDFlib is a development tool for PDF-enabling your software, 
or generating PDF on your server. PDFlib offers a simple-to-use API
for programmatically creating PDF files from within your own server- 
or client-side software. PDFlib doesn't make use of third-party software
for generating PDF, nor does it require any other tools.

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

%description devel
PDFlib is a development tool for PDF-enabling your software, 
or generating PDF on your server. PDFlib offers a simple-to-use API
for programmatically creating PDF files from within your own server- 
or client-side software. PDFlib doesn't make use of third-party software
for generating PDF, nor does it require any other tools.

This package contains the files needed for compiling programs that will use
the PDFlib library.

%package python
Summary: Python shared library for pdflib
Group: System Environment/Libraries
Requires: %{name} = %{version}-%{release}
Provides: python-pdflib = %{version}-%{release}

%description python
PDFlib is a development tool for PDF-enabling your software, 
or generating PDF on your server. PDFlib offers a simple-to-use API
for programmatically creating PDF files from within your own server- 
or client-side software. PDFlib doesn't make use of third-party software
for generating PDF, nor does it require any other tools.

This package contains the library needed for python programs 
that will use the PDFlib library.

%package perl
Summary: Perl library for pdflib
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
Provides: perl-pdflib = %{version}-%{release}

%description perl
PDFlib is a development tool for PDF-enabling your software, 
or generating PDF on your server. PDFlib offers a simple-to-use API
for programmatically creating PDF files from within your own server- 
or client-side software. PDFlib doesn't make use of third-party software
for generating PDF, nor does it require any other tools.

This package contains the library needed for perl programs 
that will use the PDFlib library.


%prep
%setup -q -n PDFlib-Lite-%{version}p3
sed -i -e "s|^PYTHONLIBDIR.*|PYTHONLIBDIR = %{python_sitearch}|" config/mkcommon.inc.in
sed -i -e "s|^PERLLIBDIR.*|PERLLIBDIR = %{perl_vendorarch}|" config/mkcommon.inc.in


%build
# java, ruby and tcl disabled.
# File a bug with RFE and patch if you need it (by fedora12).
%configure \
	--enable-large_files \
	--enable-tiffwrite \
	--disable-static \
	--with-pyincl=%{_includedir}/python%{pyver} \
	--with-py=yes \
	--with-java=no \
	--with-ruby=no \
	--with-tcl=no \
	--with-openssl \
%ifarch x86_64
	--enable-64bit \
%endif
	;

%{__make} %{?_smp_mflags}
for lang in %{binding_langs}; do
	%{__make} -C bind/pdflib/$lang
done


%install
rm -rf %{buildroot}
mkdir -p %{buildroot}%{python_sitearch}
mkdir -p %{buildroot}%{perl_vendorarch}
make install DESTDIR=%{buildroot}
for lang in %{binding_langs} ; do
	make -C bind/pdflib/$lang install DESTDIR=%{buildroot}
done

install -p -m 0644 bind/pdflib/cpp/pdflib.hpp %{buildroot}%{_includedir}/pdflib.hpp
chmod +x %{buildroot}%{_libdir}/libpdf*
chmod +x %{buildroot}%{python_sitearch}/pdflib_py.so*
chmod +x %{buildroot}%{perl_vendorarch}/pdflib_pl.so*

rm -rf examples
mkdir -p examples/{c,cpp,perl,php,python}
cp -r bind/pdflib/data examples/data
cp bind/pdflib/c/*.c bind/pdflib/c/Makefile bind/pdflib/c/readme.txt \
	examples/c
cp bind/pdflib/cpp/*.cpp bind/pdflib/cpp/Makefile bind/pdflib/cpp/readme.txt \
	examples/cpp
cp bind/pdflib/perl/*.pl bind/pdflib/perl/Makefile bind/pdflib/perl/readme.txt \
	examples/perl
cp bind/pdflib/python/*.py bind/pdflib/python/Makefile bind/pdflib/python/readme.txt \
	examples/python
cp bind/pdflib/php/*.php bind/pdflib/php/readme.txt \
	examples/php
cp bind/pdflib/php/examples.php5/*.php \
	examples/php


%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%clean
rm -rf %{buildroot}


%files
%defattr(-, root, root)
%doc readme.txt
%doc doc/pdflib/PDFlib-Lite-license.pdf
%{_bindir}/pdfimage
%{_bindir}/pdflib-config
%{_bindir}/text2pdf
%{_libdir}/libpdf.so.*

%files devel
%defattr(-, root, root)
%doc doc/pdflib/PDFlib-Lite-license.pdf
%doc doc/pdflib/changes.txt doc/pdflib/compatibility.txt
%doc doc/pdflib/PDFlib-API-reference.pdf
%doc doc/pdflib/PDFlib-tutorial.pdf
%doc doc/pdflib/readme-source-unix.txt
%doc examples
%{_bindir}/pdflib-config
%{_includedir}/pdflib.h
%{_includedir}/pdflib.hpp
%{_libdir}/libpdf.so
%exclude %{_libdir}/*.la

%files python
%defattr(-, root, root)
%doc doc/pdflib/PDFlib-Lite-license.pdf
%{python_sitearch}/pdflib_py.so*
%exclude %{python_sitearch}/*.la

%files perl
%defattr(-, root, root)
%doc doc/pdflib/PDFlib-Lite-license.pdf
%{perl_vendorarch}/pdflib_pl.*


%changelog
* Mon Nov 10 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 7.0.5-3
- updated to 7.0.5p3
- built with perl 5.16.3
- moved pdflib-lite to System Environment/Libraries Group

* Tue Jul 30 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 7.0.5-2
- rebuild with current Vine6 environment

* Mon Dec 20 2010 Shu KONNO <owa@bg.wakwak.com> 7.0.5-1
- initial build for VineSeed

