%global apiversion 0.3

Name:           libwpg
Summary:        A library for import of WordPerfect Graphics images
Summary(ja):    WordPerfect のグラフィック画像をインポートするためのライブラリ
Version:        0.3.1
Release:        1%{?_dist_release}

Group:          System Environment/Libraries
License:        LGPLv2+ or MPLv2.0
URL:            http://libwpg.sourceforge.net/

Vendor:         Project Vine
Distribution:   Vine Linux

Source0:        http://download.sourceforge.net/libwpg/%{name}-%{version}.tar.xz

BuildRoot:      %{_tmppath}/%{name}-%{version}-root
BuildRequires:  doxygen
BuildRequires:  help2man
BuildRequires:  libwpd-devel >= 0.10.0
BuildRequires:  librevenge-devel
BuildRequires:  perl(Getopt::Std)

%description
Libwpg project is a library and to work with graphics in WPG
(WordPerfect Graphics) format. WPG is the format used among others
in Corel sofware, such as WordPerfect and Presentations.


%package devel
Summary:        Development files for %{name}
Summary(ja):    %{name} の開発用ファイル
Group:          Development/Libraries
Requires:       %{name} = %{version}-%{release}

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


%package tools
Summary:        Tools to convert WordPerfect Graphics images to other formats
Summary(ja):    WordPerfect グラフィック画像を他のフォーマットに変換するツール
# wpg2svgbatch.pl says "GPL", without specifying version, and points to
# http://www.gnu.org/copyleft/gpl.html . I assume this means "any
# version".
License:        (LGPLv2+ or MPLv2.0) and GPL+
Group:          Applications/Graphics
Requires:       %{name} = %{version}-%{release}

%description tools
Tools to convert WordPerfect Graphics images to other formats. Supported
are: SVG, raw.


%package doc
Summary: Documentation of %{name} API
Summary(ja): %{name} API のドキュメント
Group: Documentation
BuildArch: noarch

%description doc
The %{name}-doc package contains API documentation for %{name}.


%prep
%setup -q


%build
%configure --disable-static --disable-werror
sed -i \
    -e 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' \
    -e 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' \
    libtool
make %{?_smp_mflags} V=1
sed 's/\r//' -i ChangeLog
find docs/doxygen/html |xargs touch -r docs/doxygen/doxygen.cfg

export LD_LIBRARY_PATH=`pwd`/src/lib/.libs${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
help2man -N -n 'debug the conversion library' -o wpg2raw.1 ./src/conv/raw/.libs/wpg2raw
help2man -N -n 'convert WordPerfect Graphics into SVG' -o wpg2svg.1 ./src/conv/svg/.libs/wpg2svg
help2man -N -n 'batch convert WordPerfect Graphics files into SVG' \
    --help-option=-h --no-discard-stderr \
    -o wpg2svgbatch.pl.1 ./src/conv/svg/wpg2svgbatch.pl

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'

# we install API docs directly from build
rm -rf %{buildroot}/%{_docdir}/%{name}

install -m 0755 -d %{buildroot}/%{_mandir}/man1
install -m 0644 wpg2*.1 %{buildroot}/%{_mandir}/man1


%clean
rm -rf $RPM_BUILD_ROOT

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


%files
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING.LGPL COPYING.MPL
%{_libdir}/%{name}-%{apiversion}.so.*

%files devel
%defattr(-,root,root,-)
%{_includedir}/%{name}-%{apiversion}
%{_libdir}/%{name}-%{apiversion}.so
%{_libdir}/pkgconfig/%{name}-%{apiversion}.pc

%files tools
%defattr(-,root,root,-)
%{_bindir}/wpg2raw
%{_bindir}/wpg2svg
%{_bindir}/wpg2svgbatch.pl
%{_mandir}/man1/wpg2raw.1*
%{_mandir}/man1/wpg2svg.1*
%{_mandir}/man1/wpg2svgbatch.pl.1*

%files doc
%doc COPYING.LGPL COPYING.MPL
%doc docs/doxygen/html


%changelog
* Sat Jul  2 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 0.3.1-1
- new upstream release.

* Tue Jan 13 2015 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 0.3.0-1
- new upstream release
- split documents to doc subpackage

* Wed Jul 02 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> - 0.2.2-1
- update to 0.2.2
- remove Patch0 (libwpg-0.1.3-nodate.patch)

* Sun Mar 27 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> - 0.2.0-3
- Initial build for Vine Linux

* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.2.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild

* Sun Dec 05 2010 Caolán McNamara <caolanm@redhat.com> - 0.2.0-1
- latest version

* Tue Jul 28 2009 Lubomir Rintel <lkundrak@v3.sk> - 0.1.3-4
- Fix multilib problem with doxygen documentation (#508940)

* Sat Jul 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.1.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.1.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Tue Jan 6 2009 Lubomir Rintel <lkundrak@v3.sk> - 0.1.3-1
- Initial packaging
