%global ctpl_docdir %{_defaultdocdir}/ctpl-%{version}

Name:           ctpl
Version:        0.3.3
Release:        3%{?_dist_release}
Summary:        Template engine library written in C
Summary(ja):    C で書かれたテンプレートエンジンライブラリ

Group:          Development/Tools
License:        GPLv3+
URL:            http://ctpl.tuxfamily.org/
Source0:        http://download.tuxfamily.org/ctpl/releases/ctpl-%{version}.tar.gz

BuildRoot:      %{_tmppath}/%{name}-%{version}-root
BuildRequires:  glib2-devel >= 2.10
Requires:       ctpl-libs = %{version}-%{release}

%description
CTPL is a template library written in C. It allows fast and easy parsing of
templates from many sources (including in-memory data and local and remote
streaming, thanks to GIO) and fine control over template parsing environment.

CTPL has following features:
* It is a library, then it can be easily used from programs
* Separated lexer and parser
* It is written in portable C
* Simple syntax
* Fast and strict parsing
* Possible in-memory parsing, allowing non-file data parsing and avoiding
  I/O-latency, through GIO's GMemoryInputStream and GMemoryOutputStream


%package libs
Summary: Template library written in C
Summary(ja): C で書かれたテンプレートライブラリ
Group: System Environment/Libraries

%description libs
This package contains the CTPL library.

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


%package devel
Summary: Development headers of the template library written in C
Summary(ja): C で書かれたテンプレートライブラリの開発ヘッダ
Group:  Development/Libraries
Requires: ctpl-libs = %{version}-%{release}

%description devel
This package contains the development headers of the CTPL library.


%package doc
Summary:   Documentation for the CTPL library
Summary:   CTPL ライブラリのドキュメント
Group:     Documentation
BuildArch: noarch
Requires:  ctpl-libs = %{version}-%{release}
Requires:  gtk-doc

%description doc
This package contains the HTML documentation reference for the CTPL library.


%prep
%setup -q

# remove waf since this isn't needed for the build, we're building the
# package with autotools
rm -f waf
rm -f wscript


%build
%configure --docdir %{ctpl_docdir}
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
make %{?_smp_mflags}


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

# Seems the --docdir flag is not working correctly, working around this here
# for now
install -d $RPM_BUILD_ROOT%{ctpl_docdir}
install -Dpm0644 AUTHORS COPYING NEWS HACKING TODO README THANKS $RPM_BUILD_ROOT%{ctpl_docdir}

rm -f $RPM_BUILD_ROOT%{_libdir}/libctpl.a
rm -f $RPM_BUILD_ROOT%{_libdir}/libctpl.la

%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%doc %{_mandir}/man1/%{name}.1.*
%{_bindir}/%{name}


%files libs
%defattr(-,root,root,-)
%dir %{ctpl_docdir}
%doc %{ctpl_docdir}/AUTHORS
%doc %{ctpl_docdir}/COPYING
%doc %{ctpl_docdir}/NEWS
%{_libdir}/lib%{name}.so.*


%files devel
%defattr(-,root,root,-)
%doc %{ctpl_docdir}/HACKING
%doc %{ctpl_docdir}/TODO
%{_libdir}/lib%{name}.so
%{_includedir}/%{name}/
%{_libdir}/pkgconfig/%{name}.pc


%files doc
%defattr(-,root,root,-)
%doc %{ctpl_docdir}/README
%doc %{ctpl_docdir}/THANKS
%doc %{_datadir}/gtk-doc/html/%{name}


%changelog
* Sat Nov  2 2014 Ryoichi INAGAKI <ryo1@toki.waseda.jp> - 0.3.3-3
- moved libs to System Environment/Libraries Group
- moved devel to Development/Libraries Group
- moved doc to Documentation Group

* Sat May 24 2014 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.3.3-2
- rebuild with new toolchain

* Sun Oct 02 2011 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.3.3-1
- new upstream release

* Sun Jan 23 2011 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.3.2-1
- new upstream release

* Wed Dec 22 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.3.1-1
- new upstream release

* Mon Sep 27 2010 Shu KONNO <owa@bg.wakwak.com> 0.2.2-2
- rebuilt with rpm-4.8.1 for pkg-config

* Sun Aug 8 2010 Toshiharu Kudoh <toshi.kd2@gmail.com> - 0.2.2-1
- initial build for VineSeed

* Sat Jul 17 2010 Dominic Hopf <dmaphy@fedoraproject.org> - 0.2.2-4
- fix rpmlint binary-or-shlib-defines-rpath error
- fix rpmlint library-without-ldconfig-* errors
- make the -doc package noarch
- remove the -bin subpackage, the binary files will now be installed with the
  main package, thus when typing 'yum install ctpl'
- require gtk-doc for the -doc package
- ctpl-libs now owns /usr/share/doc/ctpl-0.2.2
- fix redundant file listings
- require -libs package with fully qualified version for the binary package

* Fri Jul 16 2010 Dominic Hopf <dmaphy@fedoraproject.org> - 0.2.2-3
- move the %%{_libdir}/lib%%{name}.so back to the -devel package where it
  belongs to

* Fri Jul 16 2010 Dominic Hopf <dmaphy@fedoraproject.org> - 0.2.2-2
- rename subpackage lib to libs
- add Requires on the libs package to -bin, -devel and -doc package
- install %%{_libdir}/lib%%{name}.so with a -static package
- install manpage only with the binary
- install HACKING and TODO only with the -devel package
- install README and THANKS only with the -doc package
- fix the installation path for documentation files

* Thu Jul 15 2010 Dominic Hopf <dmaphy@fedoraproject.org> - 0.2.2-1
- initial specfile
